QLegendMarker Class

QLegendMarker 类是一个抽象对象,可用于访问图例中的标记。更多

公共类型

enum LegendMarkerType { LegendMarkerTypeArea, LegendMarkerTypeBar, LegendMarkerTypePie, LegendMarkerTypeXY, LegendMarkerTypeBoxPlot, LegendMarkerTypeCandlestick }

属性

公共功能

virtual ~QLegendMarker()
QBrush brush() const
QFont font() const
bool isVisible() const
QString label() const
QBrush labelBrush() const
QPen pen() const
virtual QAbstractSeries *series() = 0
void setBrush(const QBrush &brush)
void setFont(const QFont &font)
void setLabel(const QString &label)
void setLabelBrush(const QBrush &brush)
void setPen(const QPen &pen)
void setShape(QLegend::MarkerShape shape)
void setVisible(bool visible)
QLegend::MarkerShape shape() const
virtual QLegendMarker::LegendMarkerType type() = 0

信号

void brushChanged()
void clicked()
void fontChanged()
void hovered(bool status)
void labelBrushChanged()
void labelChanged()
void penChanged()
void shapeChanged()
void visibleChanged()

详细说明

图例标记由图标和标签组成。图标颜色与绘制序列所用的颜色一致,而标签则显示序列名称(或饼状序列的切片标签或条形序列的条形集标签)。图例标记总是与一个序列、切片或条形集相关。

另请参阅 QLegend

成员类型文档

enum QLegendMarker::LegendMarkerType

图例标记对象的类型。

常量说明
QLegendMarker::LegendMarkerTypeArea0区域系列的图例标记。
QLegendMarker::LegendMarkerTypeBar1条形图集的图例标记。
QLegendMarker::LegendMarkerTypePie2饼片的图例标记。
QLegendMarker::LegendMarkerTypeXY3直线、样条线或散点图系列的图例标记。
QLegendMarker::LegendMarkerTypeBoxPlot4方框图系列的图例标记
QLegendMarker::LegendMarkerTypeCandlestick5蜡烛图系列的图例标记。

属性文档

brush : QBrush

此属性保存用于填充图标的笔刷。

访问功能:

QBrush brush() const
void setBrush(const QBrush &brush)

Notifier 信号:

void brushChanged()

font : QFont

该属性用于保存标签的字体。

访问功能:

QFont font() const
void setFont(const QFont &font)

通知信号:

void fontChanged()

label : QString

该属性用于保存图例标记在图例中显示的文本。

访问功能:

QString label() const
void setLabel(const QString &label)

通知信号:

void labelChanged()

labelBrush : QBrush

该属性用于保存标签的刷子。

访问功能:

QBrush labelBrush() const
void setLabelBrush(const QBrush &brush)

通知信号:

pen : QPen

该属性用于保存绘制图标轮廓的笔。

访问功能:

QPen pen() const
void setPen(const QPen &pen)

Notifier 信号:

void penChanged()

shape : QLegend::MarkerShape

图例标记的形状。默认为QLegend::MarkerShapeDefault ,表示形状由QLegend::markerShape 属性决定。

访问功能:

QLegend::MarkerShape shape() const
void setShape(QLegend::MarkerShape shape)

Notifier 信号:

void shapeChanged()

visible : bool

该属性用于保存图例标记的可见性。

可见性同时影响图例标记标签和图标。

访问功能:

bool isVisible() const
void setVisible(bool visible)

Notifier 信号:

成员函数 文档

[virtual noexcept] QLegendMarker::~QLegendMarker()

删除图例标记。

QBrush QLegendMarker::brush() const

返回用于填充图标的笔刷。

注: 属性 brush 的获取函数。

另请参阅 setBrush()。

[signal] void QLegendMarker::brushChanged()

当图例标记的刷子发生变化时发出该信号。

注: 属性brush 的通知信号。

[signal] void QLegendMarker::clicked()

该信号在图例标记被点击时发出。

QFont QLegendMarker::font() const

读取标签的字体。

注: 属性字体的获取函数。

另请参阅 setFont().

[signal] void QLegendMarker::fontChanged()

当图例标记的(标签)字体发生变化时发出该信号。

注: 属性font 的通知信号。

[signal] void QLegendMarker::hovered(bool status)

当鼠标悬停在图例标记上时,就会发出该信号。当鼠标移到图例标记上时,status 变成true ,当鼠标再次移开时,变成false

bool QLegendMarker::isVisible() const

返回标记的可见性。

注: 属性visible 的获取函数。

QString QLegendMarker::label() const

返回标记的标签。

注: 属性标签的获取函数。

另请参阅 setLabel().

QBrush QLegendMarker::labelBrush() const

返回用于绘制标签的笔刷。

注: 属性 labelBrush 的获取函数。

另请参阅 setLabelBrush().

[signal] void QLegendMarker::labelBrushChanged()

当图例标记的标签刷发生变化时发出该信号。

注: 属性labelBrush 的通知信号。

[signal] void QLegendMarker::labelChanged()

当图例标记的标签发生变化时发出该信号。

注: 属性label 的通知信号。

QPen QLegendMarker::pen() const

返回用于绘制图标轮廓的笔。

注: pen 属性的获取函数。

另请参阅 setPen()。

[signal] void QLegendMarker::penChanged()

当图例标记的笔发生变化时会发出该信号。

注: 用于pen 属性的通知信号。

[pure virtual] QAbstractSeries *QLegendMarker::series()

返回与该图例标记相关的系列的指针。图例标记总是与系列相关。

void QLegendMarker::setBrush(const QBrush &brush)

将用于填充图标的笔刷设置为brush

注: 更改系列的颜色也会更改图标的颜色。

注: 属性brush 的设置函数。

另请参阅 brush() 。

void QLegendMarker::setFont(const QFont &font)

将标签字体设置为font

注: 属性font 的设置函数。

另请参阅 font().

void QLegendMarker::setLabel(const QString &label)

将标记的标签设置为label

注: 更改系列名称也会更改标记的标签。

注: 属性label 的设置函数。

另请参阅 label() 。

void QLegendMarker::setLabelBrush(const QBrush &brush)

将绘制标签所用的笔刷设置为brush

注: 属性labelBrush 的设置函数。

另请参阅 labelBrush().

void QLegendMarker::setPen(const QPen &pen)

将用于绘制图标轮廓的pen 设置为pen

注: 属性pen 的设置函数。

另请参阅 pen()。

void QLegendMarker::setVisible(bool visible)

将标记的可见性设置为visible

注: 属性visible 的设置函数。

另请参阅 isVisible() 。

[pure virtual] QLegendMarker::LegendMarkerType QLegendMarker::type()

返回相关系列、饼片或条形图集的图例标记类型。

另请参阅 LegendMarkerType

[signal] void QLegendMarker::visibleChanged()

当图例标记的可见性发生变化时会发出该信号。

注: 属性visible 的通知信号。

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