On this page

QDateTimeAxis Class

The QDateTimeAxis adds support for DateTime values to be added to a graph's axis. More...

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

Properties

Public Functions

QString labelFormat() const
QDateTime max() const
QDateTime min() const
qreal pan() const
void setLabelFormat(const QString &format)
void setMax(const QDateTime &max)
void setMin(const QDateTime &min)
void setPan(qreal pan)
void setSubTickCount(int newSubTickCount)
void setTickInterval(qreal newTickInterval)
void setTimeZone(const QString &zoneId)
void setZoom(qreal zoom)
int subTickCount() const
qreal tickInterval() const
QString timeZone() const
QDateTime visualMax() const
QDateTime visualMin() const
qreal zoom() const

Reimplemented Public Functions

virtual QAbstractAxis::AxisType type() const override

Signals

void labelFormatChanged(const QString &format)
void maxChanged(const QDateTime &max)
void minChanged(const QDateTime &min)
void panChanged(qreal pan)
void subTickCountChanged()
void tickIntervalChanged()
void timeZoneChanged(const QString &timeZone)
void visualMaxChanged(qreal max)
void visualMinChanged(qreal min)
void zoomChanged(qreal zoom)

Detailed Description

A DateTime Axis can be used to display DateTime representations with tick marks and grid lines. The DateTime items on the axis are displayed at the position of the ticks.

Property Documentation

labelFormat : QString

This property holds the format of the DateTime labels on the axis. The format property allows to signify the visual representation of the DateTime object, in days, months, and years. The default value is dd-MMMM-yy.

Access functions:

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

Notifier signal:

void labelFormatChanged(const QString &format)

max : QDateTime

This property holds the maximum value on the axis

This value can be lower or higher than the minimum. The DateTime is stored as UTC internally. The default value is new Date(1980,1,1)

Access functions:

QDateTime max() const
void setMax(const QDateTime &max)

Notifier signal:

void maxChanged(const QDateTime &max)

min : QDateTime

This property holds the minimum value on the axis

This value can be lower or higher than the maximum. The DateTime is stored as UTC internally. The default value is new Date(1970,1,1)

Access functions:

QDateTime min() const
void setMin(const QDateTime &min)

Notifier signal:

void minChanged(const QDateTime &min)

[since 6.11] 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.11.

Access functions:

qreal pan() const
void setPan(qreal pan)

Notifier signal:

void panChanged(qreal pan)

subTickCount : int

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:

int subTickCount() const
void setSubTickCount(int newSubTickCount)

Notifier signal:

void subTickCountChanged()

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

Notifier signal:

void tickIntervalChanged()

[since 6.11] timeZone : QString

This property holds the time zone that will be used to display labels of the axis. The accepted values are based on IANA time zone IDs. The default time zone is UTC.

This property was introduced in Qt 6.11.

Access functions:

QString timeZone() const
void setTimeZone(const QString &zoneId)

Notifier signal:

void timeZoneChanged(const QString &timeZone)

[since 6.11] 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.11.

Access functions:

qreal zoom() const
void setZoom(qreal zoom)

Notifier signal:

void zoomChanged(qreal zoom)

© 2025 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.