BarCategoryAxis QML Type
向图的坐标轴添加类别。更多...
| Import Statement: | import QtGraphs |
| In C++: | QBarCategoryAxis |
| Inherits: |
- 所有成员列表,包括继承的成员
- BarCategoryAxis 是Qt Graphs 用于2D的QML类型的一部分。
属性
- categories : list
- count : int
- labelPosition : enumeration
(since 6.11) - max : string
- min : string
信号
- categoriesChanged()
- categoryRangeChanged(string min, string max)
- countChanged()
- maxChanged(string max)
- minChanged(string min)
方法
- void append(list categories)
- void append(string category)
- string at(int index)
- void clear()
- void insert(int index, string category)
- void remove(int index)
- void remove(string category)
- void replace(string oldCategory, string newCategory)
详细说明
BarCategoryAxis 类型可配置为显示带有刻度、网格线和阴影的坐标轴线。类别会绘制在刻度之间。
以下 QML 代码片段演示了如何使用 BarCategoryAxis:
GraphsView {
anchors.fill: parent
axisX: BarCategoryAxis {
categories: ["2023", "2024", "2025"]
lineVisible: false
}
axisY: ValueAxis { }
BarSeries {
BarSet {
values: [7, 6, 9]
}
}
}属性文档
categories : list
坐标轴的类别。
count : int [read-only]
轴的类别数量。
labelPosition : enumeration [since 6.11]
| 常数 | 描述 |
|---|---|
BarCategoryAxis.Center | 标签在类别中居中。 |
BarCategoryAxis.OnValue | 标签位于类别的上边界处。 |
该属性在 Qt 6.11 中引入。
max : string
轴上的最大值。给定的值应包含在categories 中。
min : string
轴上的最小值。给定的值应包含在categories 中。
信号文档
categoriesChanged()
当坐标轴的类别发生变化时,会触发此信号。
注意: 相应的处理程序 为onCategoriesChanged 。
categoryRangeChanged(string min, string max)
当轴的分类范围发生变化时,会触发此信号。min 和max 分别是新范围的最小值和最大值。
注意: 对应的处理程序 是onCategoryRangeChanged 。
countChanged()
当某个轴的分类数量发生变化时,会触发此信号。
注意: 相应的处理程序 为onCountChanged 。
maxChanged(string max)
当轴的最大值变为max 时,会发出此信号。
注意: 相应的处理程序 为onMaxChanged 。
minChanged(string min)
当坐标轴的最小值变为min 时,将发出此信号。
注意: 相应的处理程序 为onMinChanged 。
方法文档
void append(list categories)
将categories 追加到坐标轴上。坐标轴上的最大值将更改为与categories 中最后一个类别相匹配。如果之前未定义任何类别,则坐标轴上的最小值也将更改为与categories 中第一个类别相匹配。
类别必须是有效的QString ,且不能重复。重复的类别将不会被追加。
void append(string category)
将category 追加到坐标轴上。坐标轴上的最大值将更改为与最后一个category 一致。如果之前未定义任何类别,则坐标轴上的最小值也将更改为与category 一致。
类别必须是有效的QString ,且不能重复。重复的类别将不会被追加。
string at(int index)
返回index 上的分类。
void clear()
删除所有类别。将坐标轴范围的最大值和最小值设置为 QString::null。
void insert(int index, string category)
将“category ”插入到坐标轴index 中。category 必须是有效的QString ,且不能重复。如果将category 作为前缀或后缀附加到其他类别上,坐标轴上的最小值和最大值将相应更新。
void remove(int index)
从坐标轴上删除index 处的类别。如果删除的类别当前设置了坐标轴的最大值或最小值,则会影响坐标轴的范围。
void remove(string category)
从坐标轴中删除“category ”。如果删除的类别当前为坐标轴设置了最大值或最小值,则会影响坐标轴的范围。
void replace(string oldCategory, string newCategory)
将oldCategory 替换为newCategory 。如果oldCategory 在坐标轴上不存在,则不执行任何操作。newCategory 必须是有效的QString ,且不能重复。如果替换了最小或最大类别,则坐标轴上的最小值和最大值将相应更新。
© 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.