GraphsTheme QML Type
图表的视觉样式。更多...
| Import Statement: | import QtGraphs |
| In C++: | QGraphsTheme |
- 所有成员列表,包括继承的成员
- GraphsTheme 是Qt Graphs QML 通用类型的一部分。
属性
- GraphsLine.labelTextColor : color
- GraphsLine.mainColor : color
- GraphsLine.mainWidth : real
- GraphsLine.subColor : color
- GraphsLine.subWidth : real
- axisX : GraphsLine
- axisXLabelFont : font
- axisY : GraphsLine
- axisYLabelFont : font
- axisZ : GraphsLine
- axisZLabelFont : font
- backgroundColor : color
- backgroundVisible : bool
- baseColors : list<Color>
- baseGradients : list<Gradient>
- borderColors : list<color>
- colorScheme : QGraphsTheme::ColorScheme
- colorStyle : GraphsTheme.ColorStyle
- grid : GraphsLine
- gridVisible : bool
- labelBackgroundColor : color
- labelBackgroundVisible : bool
- labelBorderVisible : bool
- labelFont : font
- labelTextColor : color
- labelsVisible : bool
- multiHighlightColor : color
- multiHighlightGradient : Gradient
- plotAreaBackgroundColor : color
- plotAreaBackgroundVisible : bool
- seriesColors : list<color>
- singleHighlightColor : color
- singleHighlightGradient : Gradient
- theme : GraphsTheme.Theme
详细说明
此类型用于指定影响整个图表的视觉属性。提供多种内置主题,既可直接使用,也可自由修改。
可以通过使用GraphsTheme.Theme.UserDefined 枚举值从头开始创建主题。
自定义主题
默认主题为 QtGreen,但可以自定义每个属性。
下表列出了由主题控制的属性以及QGraphsTheme.Theme.UserDefined 的默认值。
| 属性 | 默认值 |
|---|---|
| backgroundVisible | true |
| seriesColors | Qt::black |
| baseGradients | QLinearGradient. 基本上完全为黑色。 |
| colorStyle | Uniform |
| labelFont | QFont |
| gridVisible | true |
| labelBackgroundVisible | true |
| labelBorderVisible | true |
| labelsVisible | true |
用法示例
直接使用内置主题,无需任何修改:
Scatter3D {
theme: GraphsTheme { theme: GraphsTheme.Theme.YellowSeries }
...使用内置主题并修改部分属性:
Bars3D {
theme: GraphsTheme {
theme: GraphsTheme.Theme.QtGreenNeon
labelBorderVisible: true
labelFont.pointSize: 35
labelBackgroundVisible: false
}
...使用自定义主题:
Surface3D {
theme: GraphsTheme {
theme: GraphsTheme.Theme.UserDefined
backgroundColor: "red"
backgroundVisible: true
seriesColors: ["blue"]
colorStyle: GraphsTheme.ColorStyle.Uniform
labelFont.family: "Lucida Handwriting"
labelFont.pointSize: 35
gridVisible: false
grid.mainColor: "red"
grid.subColor: "blue"
labelBackgroundColor: "black"
labelBackgroundVisible: true
labelBorderVisible: false
labelTextColor: "white"
multiHighlightColor: "green"
singleHighlightColor: "darkRed"
}
...有关 GraphsTheme 枚举,请参阅GraphsTheme::colorStyle 和GraphsTheme::theme 。
属性文档
GraphsLine.labelTextColor : color
标签所用文本的颜色。默认值取决于colorScheme 。
GraphsLine.mainColor : color
主线的颜色。默认值取决于colorScheme 。
GraphsLine.mainWidth : real
主线的宽度。默认值为2.0 。
如果该设置用于网格线,则仅当GraphsItem3D::gridLineType 为Graphs3D.GridLineType.Shader
另请参阅 Graphs3D.GridLineType 。
GraphsLine.subColor : color
子行的颜色。默认值取决于colorScheme 。
GraphsLine.subWidth : real
子线的宽度。默认值为1.0 。
如果该设置用于网格线,则仅在GraphsItem3D::gridLineType 为Graphs3D.GridLineType.Shader
另请参阅 Graphs3D.GridLineType 。
axisX : GraphsLine
保存X轴的GraphsLine 。
另请参阅 GraphsLine.mainColor 、GraphsLine.subColor 、GraphsLine.mainWidth 、GraphsLine.subWidth 以及GraphsLine.labelTextColor 。
axisXLabelFont : font
设置axisX 上标签所使用的字体。
axisY : GraphsLine
保存Y轴的GraphsLine 。
另请参阅 GraphsLine.mainColor 、GraphsLine.subColor 、GraphsLine.mainWidth 、GraphsLine.subWidth 以及GraphsLine.labelTextColor 。
axisYLabelFont : font
设置axisY 上标签所使用的字体。
axisZ : GraphsLine
保存Z轴的GraphsLine 。
另请参阅 GraphsLine.mainColor 、GraphsLine.subColor 、GraphsLine.mainWidth 、GraphsLine.subWidth 以及GraphsLine.labelTextColor 。
axisZLabelFont : font
设置axisZ 上标签所使用的字体。
backgroundColor : color
绘制图表时所使用的视图颜色。默认值取决于colorScheme 。
backgroundVisible : bool
指定是否使用backgroundColor 的值来绘制视图背景。默认值为true 。
baseColors : list<Color> [read-only]
按系列顺序列出的、用于图中所有对象的 Color 类型基础颜色列表。如果系列数量多于颜色数量,颜色列表将循环重复,并从列表中的第一个颜色开始。如果 `colorStyle ` 不是 `GraphsTheme.ColorStyle.Uniform`,则此设置不会立即生效。
用法示例:
baseColors: [ Color { color: "red" } ]可以通过在系列中显式设置Abstract3DSeries.baseColor 来覆盖此设置。
baseGradients : list<Gradient> [read-only]
按系列顺序列出的、用于图中所有对象的基础渐变列表。如果系列数量多于渐变数量,渐变列表将循环显示,并从列表中的第一个渐变开始重新显示。
若colorStyle 的值为GraphsTheme.ColorStyle.Uniform ,则该设置不会立即生效。
用法示例:
baseGradients: [ Gradient {
GradientStop { position: 1.0; color: "#DBEB00" }
GradientStop { position: 0.0; color: "#373F26" }
} ]可以通过在系列中显式设置Abstract3DSeries.baseGradient 来覆盖此值。
borderColors : list<color>
用于图中所有对象的边框颜色列表,按系列依次排列。
如果系列数量多于颜色数量,则颜色列表将循环显示,并从列表中的第一个颜色开始重新显示。
如果 `colorStyle ` 不是 `Uniform`,则此设置不会立即生效。
colorScheme : QGraphsTheme::ColorScheme
当前图表的配色方案。
另请参阅 QGraphsTheme::ColorScheme 。
colorStyle : GraphsTheme.ColorStyle
图表颜色的样式。QGraphsTheme::ColorStyle 枚举值之一。
可以通过在系列中显式设置Abstract3DSeries.colorStyle 来覆盖此值。
注意: 在 2D 的Qt Graphs 中,此 属性无效。
另请参阅 QGraphsTheme::ColorStyle 。
grid : GraphsLine
存储主题的GraphsLine 。
另请参阅 GraphsLine.mainColor 、GraphsLine.subColor 、GraphsLine.mainWidth 、GraphsLine.subWidth 以及GraphsLine.labelTextColor 。
gridVisible : bool
用于指定是否绘制网格线。该值将影响所有网格线。默认值为true 。
labelBackgroundColor : color
标签背景的颜色。如果labelBackgroundVisible 的值为false ,则此设置无效。默认值取决于colorScheme 。
labelBackgroundVisible : bool
指定标签是使用labelBackgroundColor (包括透明度)的背景绘制,还是使用完全透明的背景绘制。 带有背景的标签会根据最长的标签长度,在每个坐标轴上绘制为相同大小,且文本居中显示。不带背景的标签则按原样绘制,并根据其在图表中的位置左对齐或右对齐。默认值为true 。
labelBorderVisible : bool
指定是否为具有背景的标签绘制边框。如果labelBackgroundVisible 的值为false ,则此设置无效。默认值为true 。
labelFont : font
设置标签所使用的字体。
labelTextColor : color
标签所用字体的颜色。
如果某个坐标轴已显式指定了labelTextColor ,则此设置无效。
默认值取决于colorScheme 。
labelsVisible : bool
用于指定是否绘制标签。如果设置为false ,则所有其他标签属性均无效。默认值为true 。
multiHighlightColor : color
所选对象的高亮颜色。当selectionMode 设置了Graphs3D.SelectionFlag.Row 或Graphs3D.SelectionFlag.Column 标志时使用。默认值取决于colorScheme 。
另请参阅 Graphs3D.SelectionFlag 。
multiHighlightGradient : Gradient
所选对象的高光渐变。当selectionMode 设置了Graphs3D.SelectionFlag.Row 或Graphs3D.SelectionFlag.Column 标志时使用。默认值取决于colorScheme 。
另请参阅 Graphs3D.SelectionFlag 。
plotAreaBackgroundColor : color
图表绘图区域背景的颜色。默认值取决于colorScheme 。
plotAreaBackgroundVisible : bool
指定是否使用plotAreaBackgroundColor 的值来绘制绘图区域的背景。默认值为true 。
seriesColors : list<color>
用于图中所有对象的颜色列表,按系列依次排列。如果系列数量多于颜色数量,颜色列表将循环,并从列表中的第一个颜色开始重新排列。如果colorStyle 的值不是GraphsTheme.ColorStyle.Uniform ,则此设置不会立即生效。
用法示例:
seriesColors: [ "red" ]可以通过在数据系列中显式设置Abstract3DSeries.baseColor 来覆盖此设置。
singleHighlightColor : color
所选对象的高亮颜色。当selectionMode 设置了Graphs3D.SelectionFlag.Item 标志时使用。默认值取决于colorScheme 。
另请参阅 Graphs3D.SelectionFlag 。
singleHighlightGradient : Gradient
所选对象的高光渐变。当selectionMode 设置了Graphs3D.SelectionFlag.Item 标志时使用。默认值取决于colorScheme 。
另请参阅 Graphs3D.SelectionFlag 。
theme : GraphsTheme.Theme
主题的类型。如果未设置类型,则类型默认为GraphsTheme.Theme.QtGreen 。在项构建完成后更改主题类型,将把主题的所有其他属性更改为预定义主题所指定的值。更改图中当前主题的类型,还会将所有关联的系列重置为使用新主题。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.