详细说明
Q3DTheme类为图形提供视觉样式。
指定影响整个图形的视觉属性。 有几个内置主题可以按原样使用或*修改。
通过使用QAbstract3DSeries属性在系列中显式设置它们,可以覆盖以下属性:baseColors,baseGradients和colorStyle。
可以使用ThemeUserDefined枚举值从头开始创建主题。 使用默认构造函数创建主题会产生一个新的用户定义主题。
默认主题
下表列出了由主题控制的属性以及ThemeUserDefined的默认值。
属性 默认值
ambientLightStrength 0.25
backgroundColor Qt::black
backgroundEnabled true
baseColors Qt::black
baseGradients QLinearGradient. Essentially fully black.
colorStyle ColorStyleUniform
font QFont
gridEnabled true
gridLineColor Qt::white
highlightLightStrength 7.5
labelBackgroundColor Qt::gray
labelBackgroundEnabled true
labelBorderEnabled true
labelTextColor Qt::white
lightColor Qt::white
lightStrength 5.0
multiHighlightColor Qt::blue
multiHighlightGradient QLinearGradient. Essentially fully black.
singleHighlightColor Qt::red
singleHighlightGradient QLinearGradient. Essentially fully black.
windowColor Qt::black
使用范例
创建内置主题而不做任何修改:
Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeQt);
创建内置主题并修改一些属性:
Q3DTheme *theme = new Q3DTheme(Q3DTheme::ThemeQt);
theme->setBackgroundEnabled(false);
theme->setLabelBackgroundEnabled(false);
创建用户定义的主题:
Q3DTheme *theme = new Q3DTheme();
theme->setAmbientLightStrength(0.3f);
theme->setBackgroundColor(QColor(QRgb(0x99ca53)));
theme->setBackgroundEnabled(true);
theme->setBaseColor(QColor(QRgb(0x209fdf)));
theme->setColorStyle(Q3DTheme::ColorStyleUniform);
theme->setFont(QFont(QStringLiteral("Impact"), 35));
theme->setGridEnabled(true);
theme->setGridLineColor(QColor(QRgb(0x99ca53)));
theme->setHighlightLightStrength(7.0f);
theme->setLabelBackgroundColor(QColor(0xf6, 0xa6, 0x25, 0xa0));
theme->setLabelBackgroundEnabled(true);
theme->setLabelBorderEnabled(true);
theme->setLabelTextColor(QColor(QRgb(0x404044)));
theme->setLightColor(Qt::white);
theme->setLightStrength(6.0f);
theme->setMultiHighlightColor(QColor(QRgb(0x6d5fd5)));
theme->setSingleHighlightColor(QColor(QRgb(0xf6a625)));
theme->setWindowColor(QColor(QRgb(0xffffff)));
设置内置主题后,对其进行一些修改:
Q3DBars *graph = new Q3DBars();
graph->activeTheme()->setType(Q3DTheme::ThemePrimaryColors);
graph->activeTheme()->setBaseColor(Qt::red);
graph->activeTheme()->setSingleHighlightColor(Qt::yellow);