QValueAxis Class | Qt Charts 5.7

Qt 5.7 | Qt Charts | C++ Classes | QValueAxis

Qt 5.7.1 Reference Documentation

# QValueAxis Class

The QValueAxis class is used for manipulating chart's axis. More...

Header: | #include <QValueAxis>
Instantiated By: | ValueAxis
Inherits: | QAbstractAxis
Inherited By: | QCategoryAxis

- List of all members, including inherited members

## Properties

- labelFormat : QString
- max : qreal
- min : qreal

- minorTickCount : int
- tickCount : int

- 27 properties inherited from QAbstractAxis
- 1 property inherited from QObject

## Public Functions

| QValueAxis(QObject *parent = Q_NULLPTR)
| ~QValueAxis()
QString | labelFormat() const
qreal | max() const
qreal | min() const
int | minorTickCount() const
void | setLabelFormat(const QString &format)
void | setMax(qreal max)
void | setMin(qreal min)
void | setMinorTickCount(int count)
void | setRange(qreal min, qreal max)
void | setTickCount(int count)
int | tickCount() const

## Reimplemented Public Functions

virtual AxisType | type() const

- 58 public functions inherited from QAbstractAxis
- 31 public functions inherited from QObject

## Public Slots

void | applyNiceNumbers()

- 1 public slot inherited from QObject

## Signals

void | labelFormatChanged(const QString &format)
void | maxChanged(qreal max)
void | minChanged(qreal min)
void | minorTickCountChanged(int minorTickCount)
void | rangeChanged(qreal min, qreal max)
void | tickCountChanged(int tickCount)

- 25 signals inherited from QAbstractAxis
- 2 signals inherited from QObject

### Additional Inherited Members

- 1 public variable inherited from QObject
- 10 static public members inherited from QObject
- 9 protected functions inherited from QObject
- 2 protected variables inherited from QObject

## Detailed Description

The QValueAxis class is used for manipulating chart's axis.

ValueAxis can be setup to show axis line with tick marks, grid lines and shades. Values of axis are drawn to position of ticks.

Example code on how to use QValueAxis.

      QChartView *chartView = new QChartView;
      QLineSeries *series = new QLineSeries;
      // ...
      chartView->chart()->addSeries(series);

      QValueAxis *axisX = new QValueAxis;
      axisX->setRange(10, 20.5);
      axisX->setTickCount(10);
      axisX->setLabelFormat("%.2f");
      chartView->chart()->setAxisX(axisX, series);

## Property Documentation

### labelFormat : QString

Defines the label format of the axis. Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, and c. See QString::sprintf() for additional details.

If the QChart::localizeNumbers is `true`, the supported specifiers are limited to: d, e, E, f, g, G, and i. Also, only the precision modifier is supported. The rest of the formatting comes from the default QLocale of the application.

Access functions:

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

Notifier signal:

void | labelFormatChanged(const QString &format)

### max : qreal

Defines the maximum value on the axis. When setting this property the min is adjusted if necessary, to ensure that the range remains valid.

Access functions:

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

Notifier signal:

void | maxChanged(qreal max)

### min : qreal

Defines the minimum value on the axis. When setting this property the max is adjusted if necessary, to ensure that the range remains valid.

Access functions:

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

Notifier signal:

void | minChanged(qreal min)

### minorTickCount : int

Defines the number of minor ticks on the axis. This indicates how many grid lines are drawn between major ticks on the chart. Labels are not drawn for minor ticks. The default value is 0.

Access functions:

int | minorTickCount() const
void | setMinorTickCount(int count)

Notifier signal:

void | minorTickCountChanged(int minorTickCount)

### tickCount : int

Defines the number of ticks on the axis. This indicates how many grid lines are drawn on the chart. The default value is 5, and it can not be below 2.

Access functions:

int | tickCount() const
void | setTickCount(int count)

Notifier signal:

void | tickCountChanged(int tickCount)

## Member Function Documentation

### QValueAxis::QValueAxis(QObject *parent = Q_NULLPTR)

Constructs an axis object which is a child of parent.

### QValueAxis::~QValueAxis()

Destroys the object

### `[slot]` void QValueAxis::applyNiceNumbers()

This method modifies range and number of ticks on the axis to look "nice". Algorithm considers numbers that can be expressed as form of 1*10^n, 2* 10^n or 5*10^n as a nice numbers. These numbers are used for spacing the ticks. This method will modify the current range and number of ticks.

See also setRange() and setTickCount().

### `[signal]` void QValueAxis::labelFormatChanged(const QString &format)

Axis emits signal when format of axis labels has changed.

Note: Notifier signal for property labelFormat.

### `[signal]` void QValueAxis::maxChanged(qreal max)

Axis emits signal when max of axis has changed.

Note: Notifier signal for property max.

### `[signal]` void QValueAxis::minChanged(qreal min)

Axis emits signal when min of axis has changed.

Note: Notifier signal for property min.

### `[signal]` void QValueAxis::minorTickCountChanged(int minorTickCount)

Axis emits signal when minorTickCount of axis has changed.

Note: Notifier signal for property minorTickCount.

### `[signal]` void QValueAxis::rangeChanged(qreal min, qreal max)

Axis emits signal when min or max of axis has changed.

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

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

### `[signal]` void QValueAxis::tickCountChanged(int tickCount)

Axis emits signal when tickCount of axis has changed.

Note: Notifier signal for property tickCount.

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

Reimplemented from QAbstractAxis::type().

Returns the type of the axis