6.0.0-rc4Source

QValueAxis Class

The QValueAxis class is an axis of real numbers. More…

Header#include <QValueAxis>
CMaketarget_link_libraries(app PRIVATE Nt::Charts)
ModuleNt Charts C++ Classes
InheritsQAbstractAxis

List of all members, including inherited members

Public Types

enumTickType

Public Functions

QValueAxis(QObject *parent = nullptr)
~QValueAxis()
voidsetMin(qreal min)
qrealmin() const
voidsetMax(qreal max)
qrealmax() const
voidsetRange(qreal min, qreal max)
voidsetTickCount(int count)
inttickCount() const
voidsetMinorTickCount(int count)
intminorTickCount() const
voidsetTickAnchor(qreal anchor)
qrealtickAnchor() const
voidsetTickInterval(qreal interval)
qrealtickInterval() const
voidsetTickType(QValueAxis::TickType type)
QValueAxis::TickTypetickType() const
voidsetLabelFormat(const QString &format)
QStringlabelFormat() const

Reimplemented Public Functions

AxisTypetype() const

Public Slots

Signals

voidminChanged(qreal min)
voidmaxChanged(qreal max)
voidrangeChanged(qreal min, qreal max)
voidtickCountChanged(int tickCount)
voidminorTickCountChanged(int tickCount)
voidlabelFormatChanged(const QString &format)
voidtickIntervalChanged(qreal interval)
voidtickAnchorChanged(qreal anchor)
voidtickTypeChanged(QValueAxis::TickType type)

Reimplemented Protected Functions

voidsetRangeFromVariant(const QVariant &min, const QVariant &max)

Detailed Description

Value axes on a line chart

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.

ConstantDescription
QValueAxis::TicksDynamicA tick at tickAnchor() and every tickInterval() from it.
QValueAxis::TicksFixedtickCount() ticks spread evenly from the minimum to the maximum.

Member Function Documentation

[explicit] 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.

[override] QValueAxis::~QValueAxis()

Destroys the axis.

[slot] 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.

[signal] 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.

[signal] 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.

[signal] 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.

[signal] void QValueAxis::minorTickCountChanged(int tickCount)

This signal is emitted when the number of minor ticks changes to tickCount.

[signal] 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.

[override, protected] 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.

[signal] 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.

[signal] 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.

[signal] 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.

[signal] void QValueAxis::tickTypeChanged(QValueAxis::TickType type)

This signal is emitted when the tick type changes to type.

[override] AxisType QValueAxis::type() const

Reimplements QAbstractAxis::type().

Returns QAbstractAxis::AxisTypeValue.