PySide6.QtGraphs.QGraphsTheme¶
- class QGraphsTheme¶
QGraphsTheme类为图表提供了视觉样式。更多…在版本6.8中添加。
概要¶
属性¶
axisXLabelFontᅟ- 用于x轴标签的字体axisYLabelFontᅟ- 用于y轴标签的字体axisZLabelFontᅟ- 用于z轴标签的字体backgroundColorᅟ- 图形绘制的视图的背景颜色。默认值取决于colorSchemebackgroundVisibleᅟ- 背景是否可见borderColorsᅟ- 用于图表中所有对象的边框颜色列表,按系列排列borderWidthᅟ- 图形中边框的宽度(如果有)。默认值为1.0gridVisibleᅟ- 是否绘制网格线labelBackgroundColorᅟ- 标签背景的颜色labelBackgroundVisibleᅟ- 标签是否以彩色背景绘制或以完全透明的背景绘制labelBorderVisibleᅟ- 是否为具有背景的标签绘制标签边框labelFontᅟ- 用于标签的字体labelTextColorᅟ- 用于标签的字体颜色。默认值取决于colorSchemelabelsVisibleᅟ- 是否绘制标签multiHighlightColorᅟ- 选中对象的高亮颜色plotAreaBackgroundColorᅟ- 图表绘图区域背景的颜色。默认值取决于colorSchemeplotAreaBackgroundVisibleᅟ- 绘图区域背景是否可见seriesColorsᅟ- 用于图表中所有对象的基础颜色列表,按系列排列singleHighlightColorᅟ- 选中对象的高亮颜色
方法¶
def
__init__()def
axisX()def
axisXLabelFont()def
axisY()def
axisYLabelFont()def
axisZ()def
axisZLabelFont()def
borderColors()def
borderWidth()def
colorScheme()def
colorStyle()def
dirtyBits()def
grid()def
isGridVisible()def
labelFont()def
labelTextColor()def
labelsVisible()def
resetDirtyBits()def
seriesColors()def
setAxisX()def
setAxisY()def
setAxisZ()def
setBorderWidth()def
setColorScheme()def
setColorStyle()def
setGrid()def
setGridVisible()def
setLabelFont()def
setTheme()def
theme()def
themeDirty()
插槽¶
信号¶
def
axisXChanged()def
axisYChanged()def
axisZChanged()def
gridChanged()def
themeChanged()def
update()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
警告
本节包含从C++自动翻译到Python的代码片段,可能包含错误。
指定影响整个图形的视觉属性。有几个内置主题可以直接使用或自由修改。
可以使用
UserDefined枚举值从头开始创建主题。使用默认构造函数创建主题会生成一个新的用户定义主题。自定义主题¶
默认主题是
QtGreen,但可以自定义每个属性。下表列出了由主题控制的属性以及
UserDefined的默认值。属性
默认值
backgroundVisibletrueQt::black
QLinearGradient。基本上是全黑的。
统一
QFont
gridVisibletruelabelBackgroundVisibletruelabelBorderVisibletruetrue使用示例¶
创建一个没有任何修改的内置主题:
theme = QGraphsTheme()
创建一个内置主题并修改一些属性:
theme = QGraphsTheme() theme.setBackgroundVisible(False) theme.setLabelBackgroundVisible(False)
修改用户定义的主题。主题的创建方式与之前的代码片段相同:
theme.setTheme(QGraphsTheme.Theme.UserDefined) theme.setBackgroundColor(QColor(QRgb(0x99ca53))) theme.setBackgroundVisible(True) colors = { QColor(QRgb(0x209fdf)) } theme.setSeriesColors(colors) theme.setColorStyle(QGraphsTheme.ColorStyle.Uniform) theme.setLabelFont(QFont("Impact", 35)) theme.setGridVisible(True) gridline = theme.grid() gridline.setMainColor(QColor(QRgb(0x99ca53))) theme.setGrid(gridline) theme.setLabelBackgroundColor(QColor(0xf6, 0xa6, 0x25, 0xa0)) theme.setLabelBackgroundVisible(True) theme.setLabelBorderVisible(True) theme.setLabelTextColor(QColor(QRgb(0x404044))) theme.setMultiHighlightColor(QColor(QRgb(0x6d5fd5))) theme.setSingleHighlightColor(QColor(QRgb(0xf6a625))) theme.setBackgroundColor(QColor(QRgb(0xffffff)))
在主题已设置为图表后修改一些属性:
quickWidget = QQuickWidget() bars = Q3DBarsWidgetItem() bars.setWidget(quickWidget) bars.widget().setMinimumSize(QSize(512, 512)) bars.activeTheme().setTheme(QGraphsTheme.Theme.MixSeries) color = { QColor(Qt.red) } bars.activeTheme().setSeriesColors(color) bars.activeTheme().setSingleHighlightColor(Qt.yellow)
- class Theme¶
内置主题。
常量
描述
QGraphsTheme.Theme.QtGreen
以绿色为基色的浅色主题。
QGraphsTheme.Theme.QtGreenNeon
以绿色霓虹灯为基色的浅色主题。
QGraphsTheme.Theme.MixSeries
一个包含多种颜色的混合主题。
QGraphsTheme.Theme.OrangeSeries
以橙色为基色的主题。
QGraphsTheme.Theme.YellowSeries
以黄色为基色的主题。
QGraphsTheme.Theme.BlueSeries
以蓝色为基色的主题。
QGraphsTheme.Theme.PurpleSeries
以紫色为基色的主题。
QGraphsTheme.Theme.GreySeries
以灰色为基色的主题。
QGraphsTheme.Theme.UserDefined
用户自定义主题。更多信息,请参见
自定义 主题。
- class ColorStyle¶
渐变类型。
常量
描述
QGraphsTheme.ColorStyle.Uniform
对象以单一颜色渲染。使用的颜色在
seriesColors、singleHighlightColor和multiHighlightColor属性中指定。QGraphsTheme.ColorStyle.ObjectGradient
对象使用每个对象的完整渐变进行着色,无论对象高度如何。使用的渐变在
seriesGradients、singleHighlightGradient和multiHighlightGradient属性中指定。QGraphsTheme.ColorStyle.RangeGradient
对象根据其高度和Y轴上的位置使用完整渐变色的一部分进行着色。使用的渐变色在
seriesGradients、singleHighlightGradient和multiHighlightGradient属性中指定。
- class ForceTheme¶
- class ColorScheme¶
表示图表的配色方案。
常量
描述
QGraphsTheme.ColorScheme.Automatic
如果可用,背景颜色遵循平台的颜色方案。如果不可用,则使用浅色外观。
QGraphsTheme.ColorScheme.Light
背景颜色比文本颜色浅,即主题是浅色的。
QGraphsTheme.ColorScheme.Dark
背景颜色比文本颜色更深,即主题是暗色的。
另请参阅
ColorScheme
- class GradientQMLStyle¶
注意
当使用
from __feature__ import true_property时,属性可以直接使用,否则通过访问器函数使用。- property axisXᅟ: QGraphsLine¶
- Access functions:
此属性保存用于x轴标签的字体。
- Access functions:
- property axisYᅟ: QGraphsLine¶
- Access functions:
此属性保存用于y轴标签的字体。
- Access functions:
- property axisZᅟ: QGraphsLine¶
- Access functions:
此属性保存用于z轴标签的字体。
- Access functions:
此属性保存图形绘制到的视图的颜色。默认值取决于
colorScheme。- Access functions:
- property backgroundVisibleᅟ: bool¶
此属性表示背景是否可见。
背景是通过使用
backgroundColor的值来绘制的。默认值为true。- Access functions:
- property borderColorsᅟ: list of QColor¶
此属性保存用于图表中所有对象的边框颜色列表,按系列排列。
如果系列数量多于颜色数量,颜色列表会循环并从列表中的第一个颜色重新开始。
如果
colorStyle不是Uniform,则不会立即生效。- Access functions:
- property borderWidthᅟ: float¶
此属性保存图形中边框的宽度(如果有)。默认值为
1.0。- Access functions:
- property colorSchemeᅟ: QGraphsTheme.ColorScheme¶
图表使用的配色方案。
另请参阅
ColorScheme- Access functions:
- property colorStyleᅟ: QGraphsTheme.ColorStyle¶
图表颜色的样式。
ColorStyle枚举值之一。这个值可以通过在系列中显式设置Abstract3DSeries.colorStyle来覆盖。
- Access functions:
- property gridᅟ: QGraphsLine¶
- Access functions:
- property gridVisibleᅟ: bool¶
此属性表示是否绘制网格线。
此值影响所有网格线。默认值为
true。- Access functions:
此属性保存标签背景的颜色。
如果
labelBackgroundVisible为false,则无效。默认值取决于colorScheme。- Access functions:
- property labelBackgroundVisibleᅟ: bool¶
此属性决定标签是否以彩色背景或完全透明背景绘制。
labelBackgroundColor值(包括 alpha)用于绘制背景。带有背景的标签会根据最长的标签在每个轴上绘制为相同大小,并且文本在其中居中。没有背景的标签则按原样绘制,并根据它们在图表中的位置左对齐或右对齐。默认值为
true。- Access functions:
- property labelBorderVisibleᅟ: bool¶
此属性保存是否绘制具有背景的标签的标签边框。
如果
labelBackgroundVisible为false,则无效。默认值为true。- Access functions:
此属性保存用于标签的字体。
- Access functions:
此属性保存用于标签的字体颜色。默认值取决于
colorScheme。- Access functions:
- property labelsVisibleᅟ: bool¶
此属性保存是否绘制标签。
如果这是
false,所有其他标签属性将无效。默认值为true。- Access functions:
此属性保存所选对象的高亮颜色。
如果
selectionMode设置了QtGraphs3D::SelectionFlag::Row或QtGraphs3D::SelectionFlag::Column标志,则使用此选项。默认值取决于colorScheme。- Access functions:
此属性保存图表绘图区域背景的颜色。默认值取决于
colorScheme。- Access functions:
- property plotAreaBackgroundVisibleᅟ: bool¶
此属性表示绘图区域背景是否可见。
背景是通过使用
plotAreaBackgroundColor的值来绘制的。默认值为true。- Access functions:
- property seriesColorsᅟ: list of QColor¶
此属性保存用于图表中所有对象的基础颜色列表,按系列逐个系列。
如果系列数量多于颜色数量,颜色列表会循环并从列表中的第一个颜色重新开始。
如果
colorStyle不是Uniform,则不会立即生效。这个值可以通过在系列中显式设置
baseColor来覆盖。- Access functions:
此属性保存所选对象的高亮颜色。
如果
selectionMode设置了QtGraphs3D::SelectionFlag::Item标志,则使用此选项。默认值取决于colorScheme。- Access functions:
- property themeᅟ: QGraphsTheme.Theme¶
主题的类型。如果未设置类型,则类型为
QtGreen。在项目构建后更改主题类型将更改主题的所有其他属性为预定义主题指定的属性。更改图表的活动主题类型还将重置所有附加的系列以使用新主题。- Access functions:
- axisX()¶
- Return type:
另请参阅
属性
axisXᅟ的获取器。- axisXChanged()¶
属性
axisXᅟ的通知信号。- axisXLabelFont()¶
- Return type:
另请参阅
属性
axisXLabelFontᅟ的获取器。- axisXLabelFontChanged()¶
属性
axisXLabelFontᅟ的通知信号。- axisY()¶
- Return type:
另请参阅
属性
axisYᅟ的获取器。- axisYChanged()¶
属性
axisYᅟ的通知信号。- axisYLabelFont()¶
- Return type:
另请参阅
属性
axisYLabelFontᅟ的获取器。- axisYLabelFontChanged()¶
属性
axisYLabelFontᅟ的通知信号。- axisZ()¶
- Return type:
另请参阅
属性
axisZᅟ的获取器。- axisZChanged()¶
属性
axisZᅟ的通知信号。- axisZLabelFont()¶
- Return type:
另请参阅
属性
axisZLabelFontᅟ的获取器。- axisZLabelFontChanged()¶
属性
axisZLabelFontᅟ的通知信号。- backgroundColor()¶
- Return type:
另请参阅
获取属性
backgroundColorᅟ的Getter。- backgroundColorChanged()¶
属性
backgroundColorᅟ的通知信号。- backgroundVisibleChanged()¶
属性
backgroundVisibleᅟ的通知信号。属性
borderColorsᅟ的获取器。- borderColorsChanged()¶
属性
borderColorsᅟ的通知信号。- borderWidth()¶
- Return type:
浮点数
另请参阅
属性
borderWidthᅟ的获取器。- borderWidthChanged()¶
属性
borderWidthᅟ的通知信号。- colorScheme()¶
- Return type:
另请参阅
属性
colorSchemeᅟ的获取器。- colorSchemeChanged()¶
属性
colorSchemeᅟ的通知信号。- colorStyle()¶
- Return type:
另请参阅
属性
colorStyleᅟ的获取器。- colorStyleChanged(type)¶
- Parameters:
类型 –
ColorStyle
属性
colorStyleᅟ的通知信号。- dirtyBits()¶
- Return type:
- grid()¶
- Return type:
另请参阅
属性
gridᅟ的获取器。- gridChanged()¶
属性
gridᅟ的通知信号。- gridVisibleChanged()¶
属性
gridVisibleᅟ的通知信号。- handleBaseColorUpdate()¶
- handleBaseGradientUpdate()¶
- isBackgroundVisible()¶
- Return type:
布尔
属性
backgroundVisibleᅟ的获取器。- isGridVisible()¶
- Return type:
布尔
属性
gridVisibleᅟ的获取器。- isLabelBackgroundVisible()¶
- Return type:
布尔
属性
labelBackgroundVisibleᅟ的获取器。- isLabelBorderVisible()¶
- Return type:
布尔
属性
labelBorderVisibleᅟ的获取器。- isPlotAreaBackgroundVisible()¶
- Return type:
布尔
属性
plotAreaBackgroundVisibleᅟ的获取器。属性
labelBackgroundColorᅟ的获取器。- labelBackgroundColorChanged()¶
属性
labelBackgroundColorᅟ的通知信号。- labelBackgroundVisibleChanged()¶
属性
labelBackgroundVisibleᅟ的通知信号。- labelBorderVisibleChanged()¶
属性
labelBorderVisibleᅟ的通知信号。- labelFont()¶
- Return type:
另请参阅
属性
labelFontᅟ的获取器。- labelFontChanged()¶
属性
labelFontᅟ的通知信号。- labelTextColor()¶
- Return type:
另请参阅
属性
labelTextColorᅟ的获取器。- labelTextColorChanged()¶
属性
labelTextColorᅟ的通知信号。- labelsVisible()¶
- Return type:
布尔
另请参阅
属性
labelsVisibleᅟ的获取器。- labelsVisibleChanged()¶
属性
labelsVisibleᅟ的通知信号。属性
multiHighlightColorᅟ的获取器。属性
multiHighlightColorᅟ的通知信号。- multiHighlightGradient()¶
- Return type:
- multiHighlightGradientChanged(gradient)¶
- Parameters:
渐变 –
QLinearGradient
- multiHighlightGradientQMLChanged()¶
属性
plotAreaBackgroundColorᅟ的获取器。- plotAreaBackgroundColorChanged()¶
属性
plotAreaBackgroundColorᅟ的通知信号。- plotAreaBackgroundVisibleChanged()¶
属性
plotAreaBackgroundVisibleᅟ的通知信号。- resetColorTheme()¶
- resetDirtyBits()¶
- resetThemeDirty()¶
属性
seriesColorsᅟ的获取器。- seriesColorsChanged(list)¶
- Parameters:
list – QColor的列表
属性
seriesColorsᅟ的通知信号。- seriesGradients()¶
- Return type:
返回主题使用的系列渐变列表。
另请参阅
- seriesGradientsChanged(list)¶
- Parameters:
list – QLinearGradient 的列表
- setAxisX(newAxisX)¶
- Parameters:
newAxisX –
QGraphsLine
另请参阅
属性
axisXᅟ的设置器。属性
axisXLabelFontᅟ的设置器。- setAxisY(newAxisY)¶
- Parameters:
newAxisY –
QGraphsLine
另请参阅
属性
axisYᅟ的设置器。属性
axisYLabelFontᅟ的设置器。- setAxisZ(newAxisZ)¶
- Parameters:
newAxisZ –
QGraphsLine
另请参阅
属性
axisZᅟ的设置器。属性
axisZLabelFontᅟ的设置器。属性
backgroundColorᅟ的设置器。- setBackgroundVisible(newBackgroundVisible)¶
- Parameters:
newBackgroundVisible – 布尔值
属性
backgroundVisibleᅟ的设置器。- setBorderColors(newBorderColors)¶
- Parameters:
newBorderColors – QColor 的列表
另请参阅
属性
borderColorsᅟ的设置器。- setBorderWidth(newBorderWidth)¶
- Parameters:
newBorderWidth – 浮点数
另请参阅
属性
borderWidthᅟ的设置器。- setColorScheme(newColorScheme)¶
- Parameters:
newColorScheme –
ColorScheme
另请参阅
属性
colorSchemeᅟ的设置器。- setColorStyle(newColorStyle)¶
- Parameters:
newColorStyle –
ColorStyle
另请参阅
属性
colorStyleᅟ的设置器。- setGrid(newGrid)¶
- Parameters:
newGrid –
QGraphsLine
另请参阅
属性
gridᅟ的设置器。- setGridVisible(newGridVisibility)¶
- Parameters:
newGridVisibility – 布尔值
另请参阅
属性
gridVisibleᅟ的设置器。属性
labelBackgroundColorᅟ的设置器。- setLabelBackgroundVisible(newLabelBackgroundVisibility)¶
- Parameters:
newLabelBackgroundVisibility – 布尔值
属性
labelBackgroundVisibleᅟ的设置器。- setLabelBorderVisible(newLabelBorderVisibility)¶
- Parameters:
newLabelBorderVisibility – 布尔值
属性
labelBorderVisibleᅟ的设置器。属性
labelFontᅟ的设置器。属性
labelTextColorᅟ的设置器。- setLabelsVisible(newLabelsVisibility)¶
- Parameters:
newLabelsVisibility – 布尔值
另请参阅
属性
labelsVisibleᅟ的设置器。属性
multiHighlightColorᅟ的设置器。- setMultiHighlightGradient(gradient)¶
- Parameters:
渐变 –
QLinearGradient
属性
plotAreaBackgroundColorᅟ的设置器。- setPlotAreaBackgroundVisible(newBackgroundVisibility)¶
- Parameters:
newBackgroundVisibility – 布尔值
属性
plotAreaBackgroundVisibleᅟ的设置器。- setSeriesColors(newSeriesColors)¶
- Parameters:
newSeriesColors – QColor 的列表
另请参阅
属性
seriesColorsᅟ的设置器。- setSeriesGradients(newSeriesGradients)¶
- Parameters:
newSeriesGradients – QLinearGradient 的列表
将
newSeriesGradients设置为主题的系列渐变。另请参阅
属性
singleHighlightColorᅟ的设置器。- setSingleHighlightGradient(gradient)¶
- Parameters:
渐变 –
QLinearGradient
- setTheme(newTheme[, force=QGraphsTheme.ForceTheme.No])¶
- Parameters:
newTheme –
Themeforce –
ForceTheme
另请参阅
属性
singleHighlightColorᅟ的获取器。属性
singleHighlightColorᅟ的通知信号。- singleHighlightGradient()¶
- Return type:
- singleHighlightGradientChanged(gradient)¶
- Parameters:
渐变 –
QLinearGradient
- singleHighlightGradientQMLChanged()¶
- theme()¶
- Return type:
另请参阅
属性
themeᅟ的获取器。属性
themeᅟ的通知信号。- themeDirty()¶
- Return type:
布尔
- update()¶