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
void setLabelFormat(const QString &format)
void setMax(const QDateTime &max)
void setMin(const QDateTime &min)
void setSubTickCount(int newSubTickCount)
void setTickInterval(qreal newTickInterval)
int subTickCount() const
qreal tickInterval() const

信号

void labelFormatChanged(const QString &format)
void maxChanged(const QDateTime &max)
void minChanged(const QDateTime &min)
void subTickCountChanged()
void tickIntervalChanged()

详细说明

日期时间轴(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)

subTickCount : int

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

访问功能

int subTickCount() const
void setSubTickCount(int newSubTickCount)

通知信号:

void subTickCountChanged()

tickInterval : qreal

该属性用于保存动态放置的刻度线和标签之间的间隔。默认值为 0,即根据最小和最大范围自动计算间隔。

访问功能:

qreal tickInterval() const
void setTickInterval(qreal newTickInterval)

通知信号:

void tickIntervalChanged()

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