在本页

QDateTimeAxis Class

QDateTimeAxis 支持将日期时间值添加到图表坐标轴。更多

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

属性

公共功能

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 QTimeZone &zoneId)
void setZoom(qreal zoom)
int subTickCount() const
qreal tickInterval() const
QTimeZone timeZone() const
QDateTime visualMax() const
QDateTime visualMin() const
qreal zoom() const

信号

void labelFormatChanged(const QString &format)
void maxChanged(const QDateTime &max)
void minChanged(const QDateTime &min)
void panChanged(qreal newPan)
void subTickCountChanged()
void tickIntervalChanged()
void timeZoneChanged(const QTimeZone &newTimeZone)
void visualMaxChanged(const QDateTime &newMax)
void visualMinChanged(const QDateTime &newMin)
void zoomChanged(qreal newZoom)

详细说明

日期时间轴(DateTime Axis)可用于显示带有刻度线和网格线的日期时间表示法。轴上的 DateTime 项目显示在刻度线的位置。

属性文档

labelFormat : QString

该属性用于保存坐标轴上 DateTime 标签的格式。格式属性允许用日、月、年来表示 DateTime 对象的可视化表示形式。默认值为 dd-MMMM-yy。

访问功能

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

通知信号

void labelFormatChanged(const QString &format)

max : QDateTime

此属性保存坐标轴上的最大值

该值可以低于或高于最小值。DateTime 内部存储为 UTC。默认值为 new Date(1980,1,1)

访问功能:

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

通知信号:

void maxChanged(const QDateTime &max)

min : QDateTime

此属性保存坐标轴上的最小值

该值可以低于或高于最大值。DateTime 内部存储为 UTC。默认值为 new Date(1970,1,1)

访问功能:

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

通知信号:

void minChanged(const QDateTime &min)

[since 6.11] pan : qreal

此属性用于保存坐标轴的平移值。

平移值会移动坐标轴的中心,但不会影响网格和标签的间隔。默认值为 0。

此属性在 Qt 6.11 中引入。

访问功能:

qreal pan() const
void setPan(qreal pan)

Notifier 信号:

void panChanged(qreal newPan)

subTickCount : int

该属性表示坐标轴上的小标点数量。这表示在图形上的主要直线之间绘制了多少个子线。副刻线不绘制标签。默认值为 0。

访问功能

int subTickCount() const
void setSubTickCount(int newSubTickCount)

通知信号:

void subTickCountChanged()

tickInterval : qreal

此属性用于设置轴上主要刻度的数量。如果值为 0 或更低,轴将自动计算适当的刻度线数量。默认值为 0。

访问功能:

qreal tickInterval() const
void setTickInterval(qreal newTickInterval)

通知信号:

void tickIntervalChanged()

[since 6.11] timeZone : QTimeZone

该属性包含用于显示坐标轴标签的时区。可接受的值基于 IANA 时区 ID。默认时区为 UTC。

此属性在 Qt 6.11 中引入。

访问函数:

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

Notifier 信号:

void timeZoneChanged(const QTimeZone &newTimeZone)

[read-only, since 6.11] visualMax : QDateTime

此属性用于保存坐标轴的可视最大值。

当轴被平移或缩放时,该属性将保存轴的可视最大值。默认值为QDateTimeAxis::max

此属性在 Qt 6.11 中引入。

访问函数:

QDateTime visualMax() const

Notifier 信号:

void visualMaxChanged(const QDateTime &newMax)

[read-only, since 6.11] visualMin : QDateTime

该属性用于保存坐标轴的视觉最小值。

当坐标轴被平移或缩放时,该属性保留坐标轴的视觉最小值。默认值为QDateTimeAxis::min

此属性在 Qt 6.11 中引入。

访问函数:

QDateTime visualMin() const

Notifier 信号:

void visualMinChanged(const QDateTime &newMin)

[since 6.11] zoom : qreal

该属性用于保存坐标轴的缩放值。缩放值可放大或缩小坐标轴,从而放大或缩小图形,但不会影响网格和标签的间隔。默认值为 1。

此属性在 Qt 6.11 中引入。

访问功能:

qreal zoom() const
void setZoom(qreal zoom)

Notifier 信号:

void zoomChanged(qreal newZoom)

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