Legend QML Type

显示图表的图例。更多

Import Statement: import QtCharts 2.9
In C++: QLegend

属性

详细说明

图例是显示图表图例的图形对象。当序列发生变化时,ChartView 类型会更新图例状态。Legend 类型属性可附加到ChartView 类型。例如

ChartView {
    legend.visible: true
    legend.alignment: Qt.AlignBottom
    // Add a few series...
}

注意: 没有可用的 QML API 来修改图例标记。可通过创建自定义图例来修改标记。更多信息,请参阅使用图例标记

属性文档

alignment : alignment

定义图例与图表对齐的方式。可以是Qt.AlignLeft,Qt.AlignRight,Qt.AlignBottom, 或Qt.AlignTop 。如果设置多个标记,结果将是未定义的。


backgroundVisible : bool

图例背景是否可见。


borderColor : color

图例的线条颜色。


color : color

图例的背景(刷子)颜色。


font : Font

图例使用的标记字体。


labelColor : color

用于绘制标签的笔刷颜色。


markerShape : enumeration

图例标记的默认形状。默认值为MarkerShapeRectangle

常量说明
Legend.MarkerShapeRectangle图例标记为矩形
Legend.MarkerShapeCircle图例标记为圆形
MarkerShapeRotatedRectangle旋转矩形图例标记。
MarkerShapeTriangle三角形图例标记
MarkerShapeStar星形图例标记
MarkerShapePentagon五角形图例标记。
Legend.MarkerShapeFromSeries图例标记形状由系列决定

另请参阅 QLegend::MarkerShape


reverseMarkers : bool

图例中的标记是否使用相反顺序。该属性默认为false


showToolTips : bool

文本截断时是否显示工具提示。该属性默认为false 。由于 QML 中不支持工具提示,因此该属性目前不起作用。


visible : bool

图例是否可见。

默认情况下,该属性为true

另请参阅 QGraphicsObject::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.