QCategoryAxis Class

The QCategoryAxis class places named ranges on the axis. More...

Header: #include <QCategoryAxis>
Instantiated By: CategoryAxis
Inherits: QValueAxis

Public Types

enum AxisLabelsPosition { AxisLabelsPositionCenter, AxisLabelsPositionOnValue }

Properties

Public Functions

QStringList categoriesLabels()
int count() const
QCategoryAxis::AxisLabelsPosition labelsPosition() const
void setLabelsPosition(QCategoryAxis::AxisLabelsPosition position)
void setStartValue(qreal min)
qreal startValue(const QString &categoryLabel = QString()) const

Signals

void labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position)

Detailed Description

This class can be used to explain the underlying data by adding labeled categories. Unlike QBarCategoryAxis, QCategoryAxis allows the widths of the category ranges to be specified freely.

Example code on how to use 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);

Member Type Documentation

enum QCategoryAxis::AxisLabelsPosition

This enum describes the position of the category labels.

ConstantValueDescription
QCategoryAxis::AxisLabelsPositionCenter0x0Labels are centered to category.
QCategoryAxis::AxisLabelsPositionOnValue0x1Labels are positioned to the high end limit of the category.

Property Documentation

categoriesLabels : const QStringList

This property holds the category labels as a string list.

Access functions:

QStringList categoriesLabels()

count : const int

This property holds the number of categories.

Access functions:

int count() const

labelsPosition : AxisLabelsPosition

This property holds the position of the category labels. The labels in the beginning and in the end of the axes may overlap other axes' labels when positioned on value.

Access functions:

QCategoryAxis::AxisLabelsPosition labelsPosition() const
void setLabelsPosition(QCategoryAxis::AxisLabelsPosition position)

Notifier signal:

void labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position)

startValue : qreal

This property holds the low end of the first category on the axis.

Access functions:

qreal startValue(const QString &categoryLabel = QString()) const
void setStartValue(qreal min)