QValueAxis Class
The QValueAxis class is an axis of real numbers. More…
| Header | #include <QValueAxis> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Charts) |
| Module | Nt Charts C++ Classes |
| Inherits | QAbstractAxis |
List of all members, including inherited members
Public Types
| enum | TickType |
Public Functions
| QValueAxis(QObject *parent = nullptr) | |
| ~QValueAxis() | |
| void | setMin(qreal min) |
| qreal | min() const |
| void | setMax(qreal max) |
| qreal | max() const |
| void | setRange(qreal min, qreal max) |
| void | setTickCount(int count) |
| int | tickCount() const |
| void | setMinorTickCount(int count) |
| int | minorTickCount() const |
| void | setTickAnchor(qreal anchor) |
| qreal | tickAnchor() const |
| void | setTickInterval(qreal interval) |
| qreal | tickInterval() const |
| void | setTickType(QValueAxis::TickType type) |
| QValueAxis::TickType | tickType() const |
| void | setLabelFormat(const QString &format) |
| QString | labelFormat() const |
Reimplemented Public Functions
| AxisType | type() const |
Public Slots
| void | applyNiceNumbers() |
Signals
| void | minChanged(qreal min) |
| void | maxChanged(qreal max) |
| void | rangeChanged(qreal min, qreal max) |
| void | tickCountChanged(int tickCount) |
| void | minorTickCountChanged(int tickCount) |
| void | labelFormatChanged(const QString &format) |
| void | tickIntervalChanged(qreal interval) |
| void | tickAnchorChanged(qreal anchor) |
| void | tickTypeChanged(QValueAxis::TickType type) |
Reimplemented Protected Functions
| void | setRangeFromVariant(const QVariant &min, const QVariant &max) |
Detailed Description

The axis has a range, set with setRange() or taken from the data of the series attached to it, and ticks: tickCount() ticks spread evenly over the range (the default), or a tick every tickInterval() from tickAnchor() with setTickType(TicksDynamic).
auto *axisY = new QValueAxis;
axisY->setRange(0, 100);
axisY->setTickCount(6);
axisY->setLabelFormat("%d %%");
chart->addAxis(axisY, Qt::AlignLeft);
series->attachAxis(axisY);
When a series is attached to an axis whose range was not set, the range becomes the extent of the data of its series. It is not changed when the data changes later; call setRange() for data that moves, as with a live plot. applyNiceNumbers() rounds the range outwards to round numbers.
See also QLogValueAxis and QAbstractAxis.
Differences from Qt
Labels are formatted by Nt itself: labelFormat() takes one printf-style conversion and no locale is applied.
Member Type Documentation
enum QValueAxis::TickType
How the ticks are placed.
| Constant | Description |
|---|---|
QValueAxis::TicksDynamic | A tick at tickAnchor() and every tickInterval() from it. |
QValueAxis::TicksFixed | tickCount() ticks spread evenly from the minimum to the maximum. |
Member Function Documentation
QValueAxis::QValueAxis(QObject *parent = nullptr)
Constructs a value axis with the given parent. Its range is 0 to 0 until it is set or taken from the data.
QValueAxis::~QValueAxis()
Destroys the axis.
void QValueAxis::applyNiceNumbers()
Widens the range to round numbers, with ticks at round numbers in between. The number of ticks may change.
QString QValueAxis::labelFormat() const
Returns the format of the labels.
void QValueAxis::labelFormatChanged(const QString &format)
This signal is emitted when the label format changes to format.
qreal QValueAxis::max() const
Returns the maximum of the axis.
void QValueAxis::maxChanged(qreal max)
This signal is emitted when the maximum of the axis changes to max.
qreal QValueAxis::min() const
Returns the minimum of the axis.
void QValueAxis::minChanged(qreal min)
This signal is emitted when the minimum of the axis changes to min.
int QValueAxis::minorTickCount() const
Returns the number of minor ticks between two ticks. The default is 0.
void QValueAxis::minorTickCountChanged(int tickCount)
This signal is emitted when the number of minor ticks changes to tickCount.
void QValueAxis::rangeChanged(qreal min, qreal max)
This signal is emitted when the range of the axis changes to min and max.
void QValueAxis::setLabelFormat(const QString &format)
Sets the format of the labels to format: text with one printf-style conversion, such as "%.1f", "%d ms" or "%5.2e". With an empty format, the default, each label has as many decimals as the ticks need.
void QValueAxis::setMax(qreal max)
Sets the maximum of the axis to max. The minimum shrinks to max if it is larger.
void QValueAxis::setMin(qreal min)
Sets the minimum of the axis to min. The maximum grows to min if it is smaller.
void QValueAxis::setMinorTickCount(int count)
Sets the number of minor ticks between two ticks to count. They have minor grid lines.
See also QAbstractAxis::setMinorGridLineVisible().
void QValueAxis::setRange(qreal min, qreal max)
Sets the range of the axis to min and max. A range whose minimum is larger than its maximum, or that is not finite, is ignored.
void QValueAxis::setRangeFromVariant(const QVariant &min, const QVariant &max)
Reimplements QAbstractAxis::setRangeFromVariant().
Sets the range to min and max, converted to real numbers. An invalid variant leaves that end as it is.
void QValueAxis::setTickAnchor(qreal anchor)
Sets the value that has a tick when the tick type is TicksDynamic to anchor.
void QValueAxis::setTickCount(int count)
Sets the number of ticks to count, at least 2. Used with TicksFixed.
void QValueAxis::setTickInterval(qreal interval)
Sets the distance between ticks when the tick type is TicksDynamic to interval.
void QValueAxis::setTickType(QValueAxis::TickType type)
Sets how the ticks are placed to type.
qreal QValueAxis::tickAnchor() const
Returns the value that has a tick when the tick type is TicksDynamic.
void QValueAxis::tickAnchorChanged(qreal anchor)
This signal is emitted when the tick anchor changes to anchor.
int QValueAxis::tickCount() const
Returns the number of ticks. The default is 5.
void QValueAxis::tickCountChanged(int tickCount)
This signal is emitted when the number of ticks changes to tickCount.
qreal QValueAxis::tickInterval() const
Returns the distance between ticks when the tick type is TicksDynamic.
void QValueAxis::tickIntervalChanged(qreal interval)
This signal is emitted when the tick interval changes to interval.
QValueAxis::TickType QValueAxis::tickType() const
Returns how the ticks are placed. The default is TicksFixed.
void QValueAxis::tickTypeChanged(QValueAxis::TickType type)
This signal is emitted when the tick type changes to type.
AxisType QValueAxis::type() const
Reimplements QAbstractAxis::type().
Returns QAbstractAxis::AxisTypeValue.