QValueAxis Class | Qt Graphs | Qt 6.11.1
Description: The QValueAxis class adds values to a graph's axes.

- Qt 6.11
- Qt Graphs
- C++ Classes
- QtGraphs
- QValueAxis
- Qt Graphs | Commercial or GPLv3

# QValueAxis Class

The QValueAxis class adds values to a graph's axes. More...

Header: | `#include <QValueAxis>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Graphs)` `target_link_libraries(mytarget PRIVATE Qt6::Graphs)`
qmake: | `QT += graphs`
In QML: | ValueAxis
Inherits: | QAbstractAxis

- List of all members, including inherited members
- QValueAxis is part of Qt Graphs C++ Classes for 2D.

## Properties

labelDecimals : int labelFormat : QString max : qreal min : qreal `(since 6.9)` pan : qreal subTickCount : qsizetype | tickAnchor : qreal tickInterval : qreal `(since 6.11)` visualMax : qreal `(since 6.11)` visualMin : qreal `(since 6.9)` zoom : qreal

## Public Functions

| QValueAxis(QObject *parent = nullptr)
virtual | ~QValueAxis() override
int | labelDecimals() const
QString | labelFormat() const
qreal | max() const
qreal | min() const
qreal | pan() const
void | setLabelDecimals(int decimals)
void | setLabelFormat(const QString &format)
void | setMax(qreal max)
void | setMin(qreal min)
void | setPan(qreal pan)
void | setRange(qreal min, qreal max)
void | setSubTickCount(qsizetype count)
void | setTickAnchor(qreal anchor)
void | setTickInterval(qreal interval)
void | setZoom(qreal zoom)
qsizetype | subTickCount() const
qreal | tickAnchor() const
qreal | tickInterval() const
qreal | visualMax() const
qreal | visualMin() const
qreal | zoom() const

## Reimplemented Public Functions

virtual QAbstractAxis::AxisType | type() const override

## Signals

void | labelDecimalsChanged(int decimals)
void | labelFormatChanged(const QString &format)
void | maxChanged(qreal max)
void | minChanged(qreal min)
void | panChanged(qreal pan)
void | subTickCountChanged(qsizetype subTickCount)
void | tickAnchorChanged(qreal tickAnchor)
void | tickIntervalChanged(qreal tickInterval)
void | visualMaxChanged(qreal newVisualMax)
void | visualMinChanged(qreal newVisualMin)
void | zoomChanged(qreal zoom)

## Detailed Description

A value axis can be set up to show an axis line with tick marks, grid lines, and shades. The values on the axis are drawn at the positions of tick marks.

## Property Documentation

### labelDecimals : int

This property holds the number of decimals used for showing the labels. When set to -1, decimal amount is adjusted automatically based on the values range. The default value is -1.

Access functions:

int | labelDecimals() const
void | setLabelDecimals(int decimals)

Notifier signal:

void | labelDecimalsChanged(int decimals)

### labelFormat : QString

This property holds the label format of the axis.

The format string supports the following conversion specifiers, length modifiers, and flags provided by `printf()` in the standard C++ library: d, i, o, x, X, f, F, e, E, g, G, c.

The default value is empty, in which case 'f' format is used.

Access functions:

QString | labelFormat() const
void | setLabelFormat(const QString &format)

Notifier signal:

void | labelFormatChanged(const QString &format)

See also QString::asprintf().

### max : qreal

This property holds the maximum value on the axis.

When setting this property, the minimum value is adjusted if necessary, to ensure that the range remains valid. The default value is 10.0

Access functions:

qreal | max() const
void | setMax(qreal max)

Notifier signal:

void | maxChanged(qreal max)

### min : qreal

This property holds the minimum value on the axis.

When setting this property, the maximum value is adjusted if necessary, to ensure that the range remains valid. The default value is 0.0

Access functions:

qreal | min() const
void | setMin(qreal min)

Notifier signal:

void | minChanged(qreal min)

### `[since 6.9]` pan : qreal

This property holds the pan value of the axis.

The pan value moves the center of the axis without affecting intervals of grid and labels. The default value is 0.

This property was introduced in Qt 6.9.

Access functions:

qreal | pan() const
void | setPan(qreal pan)

Notifier signal:

void | panChanged(qreal pan)

### subTickCount : qsizetype

This property holds the number of subticks on the axis. This indicates how many subticks are drawn between major lines on the graph. Labels are not drawn for subticks. The default value is 0.

Access functions:

qsizetype | subTickCount() const
void | setSubTickCount(qsizetype count)

Notifier signal:

void | subTickCountChanged(qsizetype subTickCount)

### tickAnchor : qreal

This property holds the base value where the dynamically placed tick marks and labels are started from. The default value is 0.

Access functions:

qreal | tickAnchor() const
void | setTickAnchor(qreal anchor)

Notifier signal:

void | tickAnchorChanged(qreal tickAnchor)

### tickInterval : qreal

This property holds the interval between dynamically placed tick marks and labels. The default value is 0, which means that intervals are automatically calculated based on the min and max range.

Access functions:

qreal | tickInterval() const
void | setTickInterval(qreal interval)

Notifier signal:

void | tickIntervalChanged(qreal tickInterval)

### `[read-only, since 6.11]` visualMax : qreal

This property holds the visual maximum value of the axis.

This property holds a a visual maximum axis value when axis has been panned or zoomed. The default value is QValueAxis::max

This property was introduced in Qt 6.11.

Access functions:

qreal | visualMax() const

Notifier signal:

void | visualMaxChanged(qreal newVisualMax)

### `[read-only, since 6.11]` visualMin : qreal

This property holds the visual minimum value of the axis.

This property holds a a visual minimum axis value when axis has been panned or zoomed. The default value is QValueAxis::min

This property was introduced in Qt 6.11.

Access functions:

qreal | visualMin() const

Notifier signal:

void | visualMinChanged(qreal newVisualMin)

### `[since 6.9]` zoom : qreal

This property holds the zoom value of the axis.

The zoom value enlarges or shrinks the axis and thus the graph without affecting intervals of grid and labels. The default value is 1.

This property was introduced in Qt 6.9.

Access functions:

qreal | zoom() const
void | setZoom(qreal zoom)

Notifier signal:

void | zoomChanged(qreal zoom)

## Member Function Documentation

### `[explicit]` QValueAxis::QValueAxis(QObject *parent = nullptr)

Constructs an axis object that is a child of parent.

### `[override virtual noexcept]` QValueAxis::~QValueAxis()

Destroys the object.

### void QValueAxis::setRange(qreal min, qreal max)

Sets the range from min to max on the axis. If min is greater than max, this function returns without making any changes.

### `[override virtual]` QAbstractAxis::AxisType QValueAxis::type() const

Reimplements: QAbstractAxis::type() const.

Returns the type of the axis.