ValueAxis QML Type

为图表的坐标轴添加数值。更多

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

AbstractAxis

属性

信号

详细说明

ValueAxis 类型可设置为显示带有刻度线、网格线和阴影的轴线。坐标轴上的值绘制在刻度线的位置上。

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

GraphsView {
    axisX: ValueAxis {
        max: 10
        tickInterval: 1
    }
    axisY: ValueAxis {
        min -20
        max: 40
    }
    LineSeries {
        // Add a few XYPoint data...
    }
}

属性文档

labelDecimals : int

用于显示标签的小数位数。设置为-1 时,将根据数值范围自动调整小数位数。默认值为-1。


labelFormat : string

格式字符串支持标准 C++ 库printf() 提供的以下转换指定符、长度修饰符和标志:d、i、o、x、X、f、F、e、E、g、G、c。

默认值为空,在这种情况下使用 "f "格式。

另请参见 QString::asprintf()。


max : real

轴上的最大值。

设置该属性时,必要时会调整最小值,以确保范围有效。默认值为 10.0


min : real

轴上的最小值。

设置此属性时,必要时会调整最大值,以确保范围保持有效。默认值为 0.0


pan : real [since 6.9]

轴的平移值。

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

此属性在 Qt 6.9 中引入。


subTickCount : int

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


tickAnchor : real

动态刻度线和标签的基准值。默认值为 0。


tickInterval : real

动态刻度线和标签之间的间隔。默认值为 0,即根据最小和最大范围自动计算间隔。


zoom : real [since 6.9]

坐标轴的缩放值。

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

此属性在 Qt 6.9 中引入。


信号文档

labelDecimalsChanged(int decimals)

当坐标轴标签小数点的数量变为decimals 时,将发出该信号。

注: 相应的处理程序是onLabelDecimalsChanged


labelFormatChanged(string format)

当坐标轴标签格式更改为format 时,将发出该信号。

注: 相应的处理程序是onLabelFormatChanged


maxChanged(real max)

当坐标轴的最大值更改为max 时,将发出此信号。

注: 相应的处理程序是onMaxChanged


minChanged(real min)

当轴的最小值变为min 时,发出此信号。

注: 相应的处理程序是onMinChanged


rangeChanged(real min, real max)

当轴的最小值或最大值分别变为minmax 时,将发出此信号。

注: 相应的处理程序为onRangeChanged


subTickCountChanged(int subTickCount)

当由subTickCount 指定的坐标轴上的子点数发生变化时,将发出此信号。

注: 相应的处理程序是onSubTickCountChanged


tickAnchorChanged(real tickAnchor)

当刻度锚定值变为tickAnchor 时,将发出此信号。

注: 相应的处理程序是onTickAnchorChanged


tickIntervalChanged(real tickInterval)

当刻度线间隔值变更为tickInterval 时,发出此信号。

注: 相应的处理程序是onTickIntervalChanged


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