在本页

DateTimeAxis QML Type

向图表坐标轴添加 DateTime 项目。更多

Import Statement: import QtGraphs
In C++: QDateTimeAxis
Inherits:

AbstractAxis

属性

信号

方法

详细说明

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

以下示例代码说明了如何使用 DateTimeAxis 类型:

GraphsView {
    axisX: DateTimeAxis {
        min: new Date(2000,1,1)
        max: new Date(1970,1,1)
    }
    LineSeries {
        // Add a few XYPoint data...
    }
}

属性文档

labelFormat : string

坐标轴上 DateTime 标签的格式 format 属性用于表示 DateTime 对象的可视化表示,单位为天、月或年。默认值为 dd-MMMM-yy。

max : real

轴上的最大值。

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

min : real

轴上的最小值。

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

pan : real [since 6.11]

坐标轴的平移值。

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

此属性在 Qt 6.11 中引入。

subTickCount : int

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

tickInterval : real

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

timeZone : QTimeZone [since 6.11]

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

此属性在 Qt 6.11 中引入。

visualMax : real [read-only, since 6.11]

轴的视觉最大值。

该属性用于保存轴被平移或缩放时的可视最大值。默认值为max

此属性在 Qt 6.11 中引入。

visualMin : real [read-only, since 6.11]

坐标轴的视觉最小值。

该属性用于保存轴被平移或缩放时的视觉最小值。默认值为min

此属性在 Qt 6.11 中引入。

zoom : real [since 6.11]

坐标轴的缩放值。缩放值可放大或缩小坐标轴,从而放大或缩小图表,但不会影响网格和标签的间隔。默认值为 1。

此属性在 Qt 6.11 中引入。

信号文档

labelFormatChanged(string format)

format 轴标签发生变化时,将发出该信号。

注: 相应的处理程序是onLabelFormatChanged

maxChanged(DateTime max)

max 指定的轴的最大值发生变化时,将发出该信号。

注: 相应的处理程序是onMaxChanged

minChanged(DateTime min)

min 指定的轴的最小值发生变化时,将发出该信号。

注: 相应的处理程序是onMinChanged

rangeChanged(real min, real max)

minmax 指定的轴的最小值或最大值发生变化时,将发出该信号。

注: 相应的处理程序是onRangeChanged

subTickCountChanged(int subTickCount)

subTickCount 指定的坐标轴上的子刻度数发生变化时,将发出该信号。

注: 相应的处理程序是onSubTickCountChanged

tickIntervalChanged(real tickInterval)

tickInterval 指定的 tick 间隔值发生变化时,将发出该信号。

注: 相应的处理程序是onTickIntervalChanged

[since 6.11] timeZoneChanged()

该信号在时区更改时发出。它表示已设置的 IANA 时区 ID 的字符串值。

注: 相应的处理程序是onTimeZoneChanged

此信号在 Qt 6.11 中引入。

[since 6.11] zoomChanged()

当缩放值发生变化时会触发该信号。

注: 相应的处理程序是onZoomChanged

此信号在 Qt 6.11 中引入。

方法文档

[since 6.11] string timeZoneAsString()

以字符串形式返回QDateTimeAxis::timeZone 基于 IANA 的区域 ID。

此方法在 Qt 6.11 中引入。

另请参阅 timeZone

[since 6.11] QTimeZone timeZoneFromString(string zoneId)

返回与基于 IANA 的zoneId 对应的QTimeZone

注: 这是设置timeZone 的转换方法。

该方法在 Qt 6.11 中引入。

另请参阅 QDateTimeAxis::timeZonetimeZoneAsString

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