QT设置三维柱状图单根柱子颜色
时间: 2023-05-23 17:02:15 浏览: 559
您可以使用以下代码来设置QT中三维柱状图的单根柱子颜色:
Q3DSurface *graph = new Q3DSurface();
QSurface3DSeries *series = new QSurface3DSeries();
QSurfaceDataArray *dataArray = new QSurfaceDataArray();
QSurfaceDataRow *dataRow = new QSurfaceDataRow();
*dataRow << QVector3D(0, 1, 5) << QVector3D(1, 2, 6) << QVector3D(2, 3, 7) << QVector3D(3, 4, 8);
dataArray->append(dataRow);
series->dataProxy()->resetArray(dataArray);
graph->addSeries(series);
QLinearGradient linearGradient(QPointF(0, 0), QPointF(0, 1));
linearGradient.setColorAt(0.0f, QColor::fromRgb(255, 0, 0));
linearGradient.setColorAt(1.0f, QColor::fromRgb(0, 0, 255));
series->setBaseGradient(linearGradient);
series->setColorStyle(Q3DTheme::ColorStyleRangeGradient);
其中,"QColor::fromRgb(255, 0, 0)",和“QColor::fromRgb(0, 0, 255)”分别代表起始和结束的颜色,你可以根据你的需要,修改这些颜色。
阅读全文