CategoryAxis QML Type
CategoryAxis 将命名区域放置在坐标轴上。更多...
| Import Statement: | import QtCharts 2.12 |
| In C++: | QCategoryAxis |
| Inherits: | |
| Status: | Deprecated |
此类型已弃用。我们强烈建议不要在新代码中使用它。
属性
- 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)
将由 `oldLabel ` 指定的现有类别标签替换为 `newLabel`。如果旧标签不存在,则该方法不进行任何更改并返回。
© 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.