QValueAxis Class

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

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

QCategoryAxis

Properties

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

Public Slots

  • 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)

Additional Inherited Members

  • 11 static public members inherited from QObject
  • 9 protected functions inherited from QObject

Detailed Description

The QValueAxis class adds values to a chart's axes.

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.

The following example code illustrates how to use the QValueAxis class:

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

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.

If 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)

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.

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.

Access functions:

qreal min() const
void setMin(qreal min)

Notifier signal:

void minChanged(qreal min)

minorTickCount : int

This property holds the number of minor tick marks 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

This property holds the number of tick marks on the axis. This indicates how many grid lines are drawn on the chart. The default value is 5, and the number cannot be less than 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 that is a child of parent.

QValueAxis::~QValueAxis()

Destroys the object.

[slot] void QValueAxis::applyNiceNumbers()

Modifies the current range and number of tick marks on the axis to look nice. The algorithm considers numbers that can be expressed as a form of 1*10^n, 2* 10^n, or 5*10^n to be nice numbers. These numbers are used for setting spacing for the tick marks.

See also setRange() and setTickCount().

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

This signal is emitted when the format of axis labels changes.

Note: Notifier signal for property labelFormat.

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

This signal is emitted when the maximum value of the axis, specified by max, changes.

Note: Notifier signal for property max.

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

This signal is emitted when the minimum value of the axis, specified by min, changes.

Note: Notifier signal for property min.

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

This signal is emitted when the number of minor tick marks on the axis, specified by minorTickCount, changes.

Note: Notifier signal for property minorTickCount.

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

This signal is emitted when the minimum or maximum value of the axis, specified by min and max, changes.

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.

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

This signal is emitted when the number of tick marks on the axis, specified by tickCount, changes.

Note: Notifier signal for property tickCount.

[virtual] AxisType QValueAxis::type() const

Reimplemented from QAbstractAxis::type().

Returns the type of the axis.

© 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.