ValueAxis QML Type
向图表的坐标轴添加数值。更多...
| Import Statement: | import QtCharts 2.12 |
| In C++: | QValueAxis |
| Inherits: | |
| Status: | Deprecated |
此类型已弃用。我们强烈建议在新代码中不要使用它。
属性
- labelFormat : string
- max : real
- min : real
- minorTickCount : int
- tickAnchor : real
(since QtCharts 2.3) - tickCount : int
- tickInterval : real
(since QtCharts 2.3) - tickType : enumeration
(since QtCharts 2.3)
信号
- rangeChanged(string min, string max)
方法
- void applyNiceNumbers()
详细说明
ValueAxis 类型可配置为显示带有刻度、网格线和阴影的坐标轴。坐标轴上的数值绘制在刻度位置处。
以下示例代码演示了如何使用 ValueAxis 类型:
属性文档
labelFormat : string
该格式字符串支持标准 C++ 库中printf() 提供的以下转换指定符、长度修饰符和标志:d、i、o、x、X、f、F、e、E、g、G、c。
如果ChartView.localizeNumbers 为true ,则支持的指定符仅限于:d、e、E、f、g、G 和 i。此外,仅支持精度修饰符。其余格式设置来自应用程序的默认QLocale 。
另请参阅 QString::asprintf()。
max : real
轴上的最大值。
设置此属性时,系统会根据需要调整最小值,以确保范围仍然有效。
min : real
轴上的最小值。
设置此属性时,系统会根据需要调整最大值,以确保范围保持有效。
minorTickCount : int
坐标轴上的小刻度数量。这表示图表中主刻度之间会绘制多少条网格线。小刻度不会显示标签。默认值为 0。
tickAnchor : real [since QtCharts 2.3]
动态放置的刻度线和标签的起始基准值。
该属性在 QtCharts 2.3 中引入。
tickCount : int
轴上的刻度数。这表示图表上绘制的网格线数量。默认值为 5,且该数值不能小于 2。
tickInterval : real [since QtCharts 2.3]
动态放置的刻度线与标签之间的间隔。
该属性在 QtCharts 2.3 中首次引入。
tickType : enumeration [since QtCharts 2.3]
刻度线和标签的定位方法。
| 常量 | 说明 |
|---|---|
ValueAxis.TicksDynamic | 刻度根据tickAnchor 和tickInterval 的值进行放置。 |
ValueAxis.TicksFixed | 刻度将均匀地分布在轴的范围内。tickCount 值指定了刻度的数量。 |
该属性在 QtCharts 2.3 中引入。
信号文档
rangeChanged(string min, string max)
当轴的min 或max 值发生变化时,会触发此信号。
相应的信号处理程序为onRangeChanged 。
注意: 相应的处理程序 为onRangeChanged 。
方法文档
void applyNiceNumbers()
调整坐标轴上当前的刻度范围和刻度数量,使其外观美观。该算法将能够表示为 1×10^n、2×10^n 或 5×10^n 形式的数值视为美观的数值。这些数值用于设置刻度的间距。
© 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.