QCategoryAxis 类
QCategoryAxis 类将命名范围放在轴上。 更多信息...
| 头文件 | #include <QCategoryAxis> | 
| 由下列类实例化 | CategoryAxis | 
| 继承自 | QValueAxis | 
公共类型
| 枚举 | AxisLabelsPosition { AxisLabelsPositionCenter, AxisLabelsPositionOnValue } | 
属性
- categoriesLabels : const QStringList
- count : const int
- labelsPosition : AxisLabelsPosition
- startValue : qreal
公共函数
| QCategoryAxis(QObject *parent = nullptr) | |
| virtual | ~QCategoryAxis() | 
| void | append(const QString &categoryLabel, qreal categoryEndValue) | 
| QStringList | categoriesLabels() | 
| int | count() const | 
| qreal | endValue(const QString &categoryLabel) const | 
| QCategoryAxis::AxisLabelsPosition | labelsPosition() const | 
| void | remove(const QString &categoryLabel) | 
| void | replaceLabel(const QString &oldLabel, const QString &newLabel) | 
| void | setLabelsPosition(QCategoryAxis::AxisLabelsPosition position) | 
| void | setStartValue(qreal min) | 
| qreal | startValue(const QString &categoryLabel = QString()) const | 
重实现的公共函数
| virtual QAbstractAxis::AxisType | type() const override | 
信号
| void | categoriesChanged() | 
| void | labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position) | 
详细描述
此类可以用于通过添加标签分类来解释底层数据。与 QBarCategoryAxis 不同,QCategoryAxis 允许自由指定分类范围的宽度。
如何使用 QCategoryAxis 的示例代码

QChartView *chartView = new QChartView; QLineSeries *series = new QLineSeries; // ... chartView->chart()->addSeries(series); QCategoryAxis *axisY = new QCategoryAxis; axisY->setMin(0); axisY->setMax(52); axisY->setStartValue(15); axisY->append("First", 20); axisY->append("Second", 37); axisY->append("Third", 52); chartView->chart()->setAxisY(axisY, series);
成员类型文档
枚举 QCategoryAxis::AxisLabelsPosition
此枚举描述了分类标签的位置。
| 常量 | 值 | 描述 | 
|---|---|---|
| QCategoryAxis::AxisLabelsPositionCenter | 0x0 | 标签居中对齐到类别。 | 
| QCategoryAxis::AxisLabelsPositionOnValue | 0x1 | 标签定位到类别的上限。 | 
属性说明
[只读] categoriesLabels : const QStringList
此属性以字符串列表的形式存储类别标签。
访问函数
| QStringList | categoriesLabels() | 
[只读] count : const int
此属性存储类别的数量。
访问函数
| int | count() const | 
labelsPosition : AxisLabelsPosition
此属性存储类别标签的位置。当定位在值上时,轴的起始和结束处的标签可能与其他轴的标签重叠。
访问函数
| QCategoryAxis::AxisLabelsPosition | labelsPosition() const | 
| void | setLabelsPosition(QCategoryAxis::AxisLabelsPosition position) | 
通知信号
| void | labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position) | 
startValue : qreal
此属性存储轴上第一个类别的下限。
访问函数
| qreal | startValue(const QString &categoryLabel = QString()) const | 
| void | setStartValue(qreal min) | 
成员函数说明
[显式] QCategoryAxis::QCategoryAxis(QObject *parent = nullptr)
构建一个轴对象,它是 parent 的子对象。
[虚拟 noexcept] QCategoryAxis::~QCategoryAxis()
销毁对象。
void QCategoryAxis::append(const QString &categoryLabel, qreal categoryEndValue)
向轴添加一个新的具有标签 categoryLabel 的类别。类别标签必须是唯一的。categoryEndValue 指定类别的上限。它必须大于上一个类别的上限。否则,该方法将返回而不添加新类别。
[信号] void QCategoryAxis::categoriesChanged()
当轴的类别更改时发出此信号。
QStringList QCategoryAxis::categoriesLabels()
返回类别标签的列表。
注意: categoriesLabels 属性的获取函数。
int QCategoryAxis::count() const
返回类别的数量。
注意: count 属性的获取函数。
qreal QCategoryAxis::endValue(const QString &categoryLabel) const
返回由 categoryLabel 指定的类别的上限。
void QCategoryAxis::remove(const QString &categoryLabel)
从轴中移除由标签 categoryLabel 指定的类别。
void QCategoryAxis::replaceLabel(const QString &oldLabel, const QString &newLabel)
将指定的 oldLabel 类别标签替换为 newLabel。如果旧标签不存在,则该方法将不做任何更改并返回。
void QCategoryAxis::setStartValue(qreal min)
将 min 设置为轴上第一个类别的下限。如果已经向轴中添加了类别,传递的值必须小于已定义的第一个类别范围的上限值。否则不执行任何操作。
注意:属性 startValue 的 setter 函数。
另请参阅:startValue()。
qreal QCategoryAxis::startValue(const QString &categoryLabel = QString()} const
返回由 categoryLabel 指定的类别的下限。
注意:属性 startValue 的 getter 函数。
另请参阅:setStartValue()。
[重写虚拟] QAbstractAxis::AxisType QCategoryAxis::type() const
重新实现: QValueAxis::type() const.
返回轴的类型。
© 2024 Qt 公司。此处包含的文档贡献均为其各自的版权所有者。提供的文档依据自由软件基金会发布的 GNU 自由文档许可证版本 1.3 许可。Qt 和相应的标志是芬兰和/或其他国家的 Qt 公司的 商标。所有其他商标均为其各自所有者的财产。