QValueAxis Class
The QValueAxis class adds values to a chart's axes. More...
| Header: | #include <QValueAxis> |
| Instantiated By: | ValueAxis |
| Inherits: | QAbstractAxis |
| Inherited By: |
Public Types
| enum | TickType { TicksDynamic, TicksFixed } |
Properties
|
|
Public Functions
| 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 | setTickAnchor(qreal anchor) |
| void | setTickCount(int count) |
| void | setTickInterval(qreal insterval) |
| void | setTickType(QValueAxis::TickType type) |
| qreal | tickAnchor() const |
| int | tickCount() const |
| qreal | tickInterval() const |
| QValueAxis::TickType | tickType() const |
Signals
| void | labelFormatChanged(const QString &format) |
| void | maxChanged(qreal max) |
| void | minChanged(qreal min) |
| void | minorTickCountChanged(int tickCount) |
| void | tickAnchorChanged(qreal anchor) |
| void | tickCountChanged(int tickCount) |
| void | tickIntervalChanged(qreal interval) |
| void | tickTypeChanged(QValueAxis::TickType type) |
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.
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);
Member Type Documentation
enum QValueAxis::TickType
This enum describes how the ticks and labels are positioned on the axis.
| Constant | Value | Description |
|---|---|---|
QValueAxis::TicksDynamic | 0 | Ticks are placed according to tickAnchor and tickInterval values. |
QValueAxis::TicksFixed | 1 | Ticks are placed evenly across the axis range. The tickCount value specifies the number of ticks. |
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 tickCount) |
tickAnchor : qreal
This property holds the base value where the dynamically placed tick marks and labels are started from.
This property was introduced in Qt 5.12.
Access functions:
| qreal | tickAnchor() const |
| void | setTickAnchor(qreal anchor) |
Notifier signal:
| void | tickAnchorChanged(qreal anchor) |
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) |
tickInterval : qreal
This property holds the interval between dynamically placed tick marks and labels.
This property was introduced in Qt 5.12.
Access functions:
| qreal | tickInterval() const |
| void | setTickInterval(qreal insterval) |
Notifier signal:
| void | tickIntervalChanged(qreal interval) |
tickType : TickType
This property holds the positioning method of tick and labels.
This property was introduced in Qt 5.12.
Access functions:
| QValueAxis::TickType | tickType() const |
| void | setTickType(QValueAxis::TickType type) |
Notifier signal:
| void | tickTypeChanged(QValueAxis::TickType type) |