CategoryAxis QML Type
CategoryAxis 将命名的范围放置在坐标轴上。更多
| Import Statement: | import QtCharts 2.11 |
| In C++: | QCategoryAxis |
| Inherits: |
属性
- categoriesLabels : StringList
- count : int
- labelsPosition : enumeration
- startValue : int
方法
- void append(string label, real endValue)
- void remove(string label)
- void replace(string oldLabel, string newLabel)
详细描述
该类型可通过添加标注类别来解释基础数据。类别范围的宽度可以自由指定。
例如

ChartView { title: "Numerical Data for Dummies" anchors.fill: parent legend.visible: false antialiasing: true LineSeries { axisY: CategoryAxis { min: 0 max: 30 CategoryRange { label: "critical" endValue: 2 } CategoryRange { label: "low" endValue: 4 } CategoryRange { label: "normal" endValue: 7 } CategoryRange { label: "high" endValue: 15 } CategoryRange { label: "extremely high" endValue: 30 } } XYPoint { x: 0; y: 4.3 } XYPoint { x: 1; y: 4.1 } XYPoint { x: 2; y: 4.7 } XYPoint { x: 3; y: 3.9 } XYPoint { x: 4; y: 5.2 } } }
属性文档
categoriesLabels : StringList [read-only]
以字符串形式列出的类别标签。
count : int [read-only]
类别数量。
labelsPosition : enumeration
类别标签的位置。坐标轴开头和结尾的标签可能会与其他坐标轴的标签重叠。
| 常数 | 说明 |
|---|---|
CategoryAxis.AxisLabelsPositionCenter | 标签居中于类别。 |
CategoryAxis.AxisLabelsPositionOnValue | 标签定位到类别的上限。 |
startValue : int
坐标轴上第一个类别的低端。
方法文档
void append(string label, real endValue)
在轴上添加一个新类别,标签为label 。类别标签必须是唯一的。endValue 指定类别的上限。它必须大于前一个类别的上限。否则,该方法将返回,但不会添加新的类别。
void remove(string label)
从坐标轴上删除标签label 指定的类别。
void replace(string oldLabel, string newLabel)
用newLabel 替换oldLabel 指定的现有类别标签。如果旧标签不存在,方法返回,不做任何更改。
© 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.