GraphsTheme QML Type
图形的可视化样式更多
| Import Statement: | import QtGraphs |
| In C++: | QGraphsTheme |
- 所有成员(包括继承成员)的列表
- GraphsTheme 是Qt Graphs QML Common Types 的一部分。
属性
- 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 | 统一 |
| 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]
颜色类型的基本颜色列表,用于图形中的所有对象,按系列排列。如果系列数多于颜色数,颜色列表将重新打包,并从列表中的第一种颜色开始。如果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 不是统一颜色,则不会立即生效。
colorScheme : QGraphsTheme::ColorScheme
使用中的图表配色方案。
另请参见 QGraphsTheme::ColorScheme 。
colorStyle : GraphsTheme.ColorStyle
图形颜色的样式。QGraphsTheme::ColorStyle 枚举值之一。
可以通过在系列中明确设置Abstract3DSeries.colorStyle 来覆盖此值。
注: 该属性在Qt Graphs for 2D 中不起作用。
另请参阅 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 (包括 alpha)背景还是全透明背景绘制标签。有背景的标签根据最长的标签绘制,每个轴的尺寸相等,文本居中。无背景的标签按原样绘制,并根据其在图表中的位置向左或向右对齐。默认值为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.