The QValueAxis class adds values to a chart's axes. 更多...
头: | #include <QValueAxis> |
实例化: | ValueAxis |
继承: | QAbstractAxis |
继承者: | QCategoryAxis |
enum | TickType { TicksDynamic, TicksFixed } |
|
|
QValueAxis (QObject * parent = nullptr) | |
virtual | ~QValueAxis () |
QString | labelFormat () const |
qreal | max () const |
qreal | min () const |
int | minorTickCount () const |
void | setLabelFormat (const QString & format ) |
void | setMax (qreal max ) |
void | setMin (qreal min ) |
void | setMinorTickCount (int count ) |
void | setRange (qreal min , qreal max ) |
void | setTickAnchor (qreal anchor ) |
void | setTickCount (int count ) |
void | setTickInterval (qreal insterval ) |
void | setTickType (QValueAxis::TickType type ) |
qreal | tickAnchor () const |
int | tickCount () const |
qreal | tickInterval () const |
QValueAxis::TickType | tickType () const |
virtual QAbstractAxis::AxisType | type () const override |
void | applyNiceNumbers () |
void | labelFormatChanged (const QString & format ) |
void | maxChanged (qreal max ) |
void | minChanged (qreal min ) |
void | minorTickCountChanged (int minorTickCount ) |
void | rangeChanged (qreal min , qreal max ) |
void | tickAnchorChanged (qreal anchor ) |
void | tickCountChanged (int tickCount ) |
void | tickIntervalChanged (qreal interval ) |
void | tickTypeChanged (QValueAxis::TickType type ) |
A value axis can be set up to show an axis line with tick marks, grid lines, and shades. The values on the axis are drawn at the positions of tick marks.
The following example code illustrates how to use the QValueAxis class:
QChartView *chartView = new QChartView; QLineSeries *series = new QLineSeries; // ... chartView->chart()->addSeries(series); QValueAxis *axisX = new QValueAxis; axisX->setRange(10, 20.5); axisX->setTickCount(10); axisX->setLabelFormat("%.2f"); chartView->chart()->setAxisX(axisX, series);
This enum describes how the ticks and labels are positioned on the axis.
常量 | 值 | 描述 |
---|---|---|
QValueAxis::TicksDynamic
|
0
|
Ticks are placed according to tickAnchor and tickInterval 值。 |
QValueAxis::TicksFixed
|
1
|
Ticks are placed evenly across the axis range. The tickCount value specifies the number of ticks. |
此特性保持轴的标签格式。
格式字符串支持的以下转换说明符、长度修饰符和标志的提供通过
printf()
在标准 C++ 库:d、i、o、x、X、f、F、e、E、g、G、c。
若
QChart::localizeNumbers
is
true
,支持的说明符限于:d、e、E、f、g、G 和 i。另外,仅支持精度修饰符。其余格式来自默认
QLocale
对于应用程序。
访问函数:
QString | labelFormat () const |
void | setLabelFormat (const QString & format ) |
通知程序信号:
void | labelFormatChanged (const QString & format ) |
另请参阅 QString::asprintf ().
此特性保持轴的最大值。
When setting this property, the minimum value is adjusted if necessary, to ensure that the range remains valid.
访问函数:
qreal | max () const |
void | setMax (qreal max ) |
通知程序信号:
void | maxChanged (qreal max ) |
此特性保持轴的最小值。
When setting this property, the maximum value is adjusted if necessary, to ensure that the range remains valid.
访问函数:
qreal | min () const |
void | setMin (qreal min ) |
通知程序信号:
void | minChanged (qreal min ) |
此特性保持轴的次要刻度标记数。这指示在图表主要刻度之间要绘制多少栅格线。次要刻度不绘制标签。默认值为 0。
访问函数:
int | minorTickCount () const |
void | setMinorTickCount (int count ) |
通知程序信号:
void | minorTickCountChanged (int minorTickCount ) |
[since 5.12]
tickAnchor
:
qreal
此特性保持从哪里开始动态放置刻度标记和标签的值。
该特性在 Qt 5.12 引入。
访问函数:
qreal | tickAnchor () const |
void | setTickAnchor (qreal anchor ) |
通知程序信号:
void | tickAnchorChanged (qreal anchor ) |
This property holds the number of tick marks on the axis. This indicates how many grid lines are drawn on the chart. The default value is 5, and the number cannot be less than 2.
访问函数:
int | tickCount () const |
void | setTickCount (int count ) |
通知程序信号:
void | tickCountChanged (int tickCount ) |
[since 5.12]
tickInterval
:
qreal
此特性保持动态放置刻度标记和标签之间的间隔。
该特性在 Qt 5.12 引入。
访问函数:
qreal | tickInterval () const |
void | setTickInterval (qreal insterval ) |
通知程序信号:
void | tickIntervalChanged (qreal interval ) |
[since 5.12]
tickType
:
TickType
此特性保持刻度和标签的定位方法。
该特性在 Qt 5.12 引入。
访问函数:
QValueAxis::TickType | tickType () const |
void | setTickType (QValueAxis::TickType type ) |
通知程序信号:
void | tickTypeChanged (QValueAxis::TickType type ) |
Constructs an axis object that is a child of parent .
[slot]
void
QValueAxis::
applyNiceNumbers
()
修改轴的当前范围和刻度标记数,以使看起来 nice . The algorithm considers numbers that can be expressed as a form of 1*10^n, 2* 10^n, or 5*10^n to be nice numbers. These numbers are used for setting spacing for the tick marks.
另请参阅 setRange () 和 setTickCount ().
[signal]
void
QValueAxis::
labelFormatChanged
(const
QString
&
format
)
此信号被发射当 format 对于轴标签改变。
注意: 通知程序信号对于特性 labelFormat .
[signal]
void
QValueAxis::
maxChanged
(
qreal
max
)
This signal is emitted when the maximum value of the axis, specified by max ,改变。
注意: 通知程序信号对于特性 max .
[signal]
void
QValueAxis::
minChanged
(
qreal
min
)
This signal is emitted when the minimum value of the axis, specified by min ,改变。
注意: 通知程序信号对于特性 min .
[signal]
void
QValueAxis::
minorTickCountChanged
(
int
minorTickCount
)
This signal is emitted when the number of minor tick marks on the axis, specified by minorTickCount ,改变。
注意: 通知程序信号对于特性 minorTickCount .
[signal]
void
QValueAxis::
rangeChanged
(
qreal
min
,
qreal
max
)
This signal is emitted when the minimum or maximum value of the axis, specified by min and max ,改变。
[signal]
void
QValueAxis::
tickCountChanged
(
int
tickCount
)
This signal is emitted when the number of tick marks on the axis, specified by tickCount ,改变。
注意: 通知程序信号对于特性 tickCount .
[virtual]
QValueAxis::
~QValueAxis
()
销毁对象。
设置范围从 min to max 在轴。若 min 大于 max ,此函数返回不做任何改变。
[override virtual]
QAbstractAxis::AxisType
QValueAxis::
type
() const
重实现: QAbstractAxis::type () const.
返回轴的类型。