Legend QML Type
显示图表的图例。更多...
| Import Statement: | import QtCharts 2.12 |
| In C++: | QLegend |
| Status: | Deprecated |
此类型已弃用。我们强烈建议不要在新代码中使用它。
属性
- alignment : alignment
- backgroundVisible : bool
- borderColor : color
- color : color
- font : Font
- labelColor : color
- markerShape : enumeration
- reverseMarkers : bool
- showToolTips : bool
- visible : bool
详细说明
图例是一种用于显示图表图例的图形对象。当系列发生变化时,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 。
© 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.