GraphsTheme QML Type

图形的可视化样式更多

Import Statement: import QtGraphs
In C++: QGraphsTheme

属性

详细描述

该类型用于指定影响整个图形的可视化属性。有几种内置主题,可按原样使用或自由修改。

也可以使用GraphsTheme.Theme.UserDefined 枚举值从头开始创建主题。

自定义主题

默认主题为 QtGreen,但也可以自定义每个属性。

下表列出了由主题控制的属性以及QGraphsTheme.Theme.UserDefined 的默认值。

使用示例

使用内置主题,不做任何修改:

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::colorStyleGraphsTheme::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



axisXLabelFont : font

设置axisX 上标签使用的字体。



axisYLabelFont : font

设置用于axisY 上标签的字体。



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]

用于图形中所有对象的基本渐变效果列表,按系列排列。如果系列数多于渐变效果,渐变效果列表将重新打包,并从列表中的第一个渐变效果开始。

如果colorStyleGraphsTheme.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



gridVisible : bool

定义是否绘制网格线。该值会影响所有网格线。默认值为true


labelBackgroundColor : color

标签背景颜色。如果labelBackgroundVisiblefalse 则无影响。默认值取决于colorScheme


labelBackgroundVisible : bool

定义是使用labelBackgroundColor (包括 alpha)背景还是全透明背景绘制标签。有背景的标签根据最长标签绘制,每个轴的尺寸相等,文本居中。无背景的标签按原样绘制,并根据其在图表中的位置向左或向右对齐。默认值为true


labelBorderVisible : bool

定义是否为有背景的标签绘制标签边框。如果labelBackgroundVisiblefalse ,则无影响。默认值为true


labelFont : font

设置标签使用的字体。


labelTextColor : color

标签所用字体的颜色。

如果轴已明确指定 labelTextColor,则该值无效。

默认值取决于colorScheme


labelsVisible : bool

定义是否绘制标签。如果设置为false ,则所有其他标签属性都不起作用。默认值为true


multiHighlightColor : color

选定对象的高亮颜色。在selectionMode 设置了Graphs3D.SelectionFlag.RowGraphs3D.SelectionFlag.Column 标志时使用。默认值取决于colorScheme

另请参阅 Graphs3D.SelectionFlag


multiHighlightGradient : Gradient

所选对象的高亮渐变色。在selectionMode 设置了Graphs3D.SelectionFlag.RowGraphs3D.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 。在构建项目后更改主题类型,会将主题的所有其他属性更改为预定义主题指定的属性。更改图表活动主题的主题类型也会重置所有附加序列,使其使用新主题。


© 2025 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.