BarCategoryAxis QML Type
为图表的坐标轴添加类别。更多
Import Statement: | import QtGraphs |
In C++: | QBarCategoryAxis |
Inherits: |
- 所有成员的列表,包括继承成员
- BarCategoryAxis 是Qt Graphs QML Types for 2D 的一部分。
属性
- categories : list
- count : int
- max : string
- min : string
信号
- categoriesChanged()
- categoryRangeChanged(string min, string max)
- countChanged()
- maxChanged(string max)
- minChanged(string min)
方法
- append(list categories)
- append(string category)
- string at(int index)
- clear()
- insert(int index, string category)
- remove(int index)
- remove(string category)
- 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 |
轴的类别数。
max : string |
轴上的最大值。给定值应包含在categories
中。
min : string |
坐标轴上的最小值。给定值应包含在categories
中。
信号文档
categoriesChanged() |
当轴的类别发生变化时,将发出该信号。
注: 相应的处理程序是onCategoriesChanged
。
min 和max 是新范围的最小值和最大值。
注: 相应的处理程序是onCategoryRangeChanged
。
countChanged() |
当轴的类别数发生变化时,将发出此信号。
注: 相应的处理程序是onCountChanged
。
maxChanged(string max) |
当轴的最大值变为max 时,将发出此信号。
注: 相应的处理程序是onMaxChanged
。
minChanged(string min) |
当轴的最小值变为min 时,将发出此信号。
注: 相应的处理程序是onMinChanged
。
方法文档
append(list categories) |
将categories 添加到坐标轴。轴上的最大值将更改为与categories 中的最后一个类别相匹配。如果之前没有定义类别,轴上的最小值也将更改为与categories 中的第一个类别相匹配。
类别必须是有效的QString ,并且不能重复。重复的类别不会被添加。
append(string category) |
将category 附加到坐标轴。轴上的最大值将更改为与最后一个category 匹配。如果之前未定义任何类别,轴上的最小值也将改为与category 匹配。
类别必须是有效的QString ,并且不能重复。重复的类别将不会被添加。
clear() |
删除所有类别。将坐标轴范围的最大值和最小值设置为 QString::null。
将category 插入index 处的轴。category 必须是有效的QString ,且不能重复。如果category 被预置或附加到其他类别,坐标轴上的最小值和最大值也会相应更新。
remove(int index) |
从坐标轴上删除index 的类别。删除当前设置坐标轴最大或最小值的类别会影响坐标轴范围。
remove(string category) |
从坐标轴中移除category 。移除当前在坐标轴上设置最大或最小值的类别会影响坐标轴范围。
用newCategory 替换oldCategory 。如果轴上不存在oldCategory ,则不会执行任何操作。newCategory 必须是有效的QString ,且不能重复。如果最小或最大类别被替换,轴上的最小值和最大值也会相应更新。
© 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.