QAbstractAxis Class
QAbstractAxis 类是用于特定轴类的基类。更多内容...
| 头文件: | #include <QAbstractAxis> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Graphs) target_link_libraries(mytarget PRIVATE Qt6::Graphs) |
| qmake: | QT += graphs |
| 在 QML 中: | AbstractAxis |
| 继承自: | QObject |
| 被继承自: |
- 所有成员列表(包括继承的成员)
- QAbstractAxis 属于Qt Graphs 的2D C++ 类。
公共类型
| enum class | AxisType { Value, BarCategory, DateTime, LogValue } |
属性
|
|
公共函数
| virtual | ~QAbstractAxis() override |
| Qt::Alignment | alignment() const |
| QColor | color() const |
| void | hide() |
| bool | isGridVisible() const |
| bool | isLineVisible() const |
| bool | isSubGridVisible() const |
| bool | isTitleVisible() const |
| bool | isVisible() const |
| QQmlComponent * | labelDelegate() const |
| qreal | labelsAngle() const |
| bool | labelsVisible() const |
| void | setAlignment(Qt::Alignment alignment) |
| void | setColor(QColor color) |
| void | setGridVisible(bool visible = true) |
| void | setLabelDelegate(QQmlComponent *newLabelDelegate) |
| void | setLabelsAngle(qreal angle) |
| void | setLabelsVisible(bool visible = true) |
| void | setLineVisible(bool visible = true) |
| void | setMax(const QVariant &max) |
| void | setMin(const QVariant &min) |
| void | setRange(const QVariant &min, const QVariant &max) |
| void | setSubColor(QColor color) |
| void | setSubGridVisible(bool visible = true) |
| void | setTextElideMode(Qt::TextElideMode elideMode) |
| void | setTitleColor(QColor color) |
| void | setTitleFont(const QFont &font) |
| void | setTitleText(const QString &title) |
| void | setTitleVisible(bool visible = true) |
| void | setVisible(bool visible = true) |
| void | show() |
| QColor | subColor() const |
| Qt::TextElideMode | textElideMode() const |
| QColor | titleColor() const |
| QFont | titleFont() const |
| QString | titleText() const |
| virtual QAbstractAxis::AxisType | type() const = 0 |
信号
| void | alignmentChanged(Qt::Alignment alignment) |
| void | colorChanged(QColor newColor) |
| void | gridVisibleChanged(bool visible) |
| void | labelDelegateChanged() |
| void | labelsAngleChanged(qreal angle) |
| void | labelsVisibleChanged(bool visible) |
| void | lineVisibleChanged(bool visible) |
| void | subColorChanged(QColor newColor) |
| void | subGridVisibleChanged(bool visible) |
| void | textElideModeChanged(Qt::TextElideMode elideMode) |
| void | titleColorChanged(QColor color) |
| void | titleFontChanged(const QFont &font) |
| void | titleTextChanged(const QString &title) |
| void | titleVisibleChanged(bool visible) |
| void | update() |
| void | visibleChanged(bool visible) |
成员类型文档
enum class QAbstractAxis::AxisType
此枚举类型指定了轴对象的类型。
| 常量 | 常量值 |
|---|---|
QAbstractAxis::AxisType::Value | 0 |
QAbstractAxis::AxisType::BarCategory | 1 |
QAbstractAxis::AxisType::DateTime | 2 |
QAbstractAxis::AxisType::LogValue (since Qt 6.12) | 3 |
属性文档
[since 6.9] alignment : Qt::Alignment
该属性用于指定坐标轴的对齐方式。
取值可以是Qt::AlignLeft 、Qt::AlignRight 、Qt::AlignBottom 或Qt::AlignTop 。
该枚举类型自 Qt 6.9 起引入。
访问函数:
| Qt::Alignment | alignment() const |
| void | setAlignment(Qt::Alignment alignment) |
通知器信号:
| void | alignmentChanged(Qt::Alignment alignment) |
color : QColor
此属性用于指定绘制主刻度和坐标轴线所使用的颜色。
即使主题发生变化,该属性也会覆盖主题颜色。
访问函数:
| QColor | color() const |
| void | setColor(QColor color) |
通知信号:
| void | colorChanged(QColor newColor) |
gridVisible : bool
该属性控制网格线的可见性。默认情况下,其值为true 。
访问函数:
| bool | isGridVisible() const |
| void | setGridVisible(bool visible = true) |
通知信号:
| void | gridVisibleChanged(bool visible) |
labelDelegate : QQmlComponent*
该属性包含一个用作坐标轴标签的自定义 QML 组件。该组件应为Text 组件,或包含“属性字符串文本”,以便将标签的值赋给该属性。
访问函数:
| QQmlComponent * | labelDelegate() const |
| void | setLabelDelegate(QQmlComponent *newLabelDelegate) |
通知信号:
| void | labelDelegateChanged() |
labelsAngle : qreal
该属性存储轴标签的角度(单位为度)。
访问函数:
| qreal | labelsAngle() const |
| void | setLabelsAngle(qreal angle) |
通知信号:
| void | labelsAngleChanged(qreal angle) |
labelsVisible : bool
该属性控制坐标轴标签是否可见。默认情况下,其值为true 。
访问函数:
| bool | labelsVisible() const |
| void | setLabelsVisible(bool visible = true) |
通知信号:
| void | labelsVisibleChanged(bool visible) |
lineVisible : bool
该属性控制坐标轴线的可见性。默认情况下,其值为true 。
访问函数:
| bool | isLineVisible() const |
| void | setLineVisible(bool visible = true) |
通知信号:
| void | lineVisibleChanged(bool visible) |
subColor : QColor
此属性用于指定绘制子刻度线所用的颜色。
即使主题发生变化,该属性也会覆盖主题颜色。
访问函数:
| QColor | subColor() const |
| void | setSubColor(QColor color) |
通知信号:
| void | subColorChanged(QColor newColor) |
subGridVisible : bool
该属性控制子网格线的可见性。
仅适用于支持子网格线的坐标轴。默认情况下,该值为true 。
访问函数:
| bool | isSubGridVisible() const |
| void | setSubGridVisible(bool visible = true) |
通知信号:
| void | subGridVisibleChanged(bool visible) |
[since 6.10] textElideMode : Qt::TextElideMode
该属性用于指定溢出文本中省略号的位置。
可取值为Qt::ElideLeft 、Qt::ElideRight 、Qt::ElideMiddle 或Qt::ElideNone 。默认值为Qt::ElideNone 。
该枚举类型在 Qt 6.10 中引入。
访问函数:
| Qt::TextElideMode | textElideMode() const |
| void | setTextElideMode(Qt::TextElideMode elideMode) |
通知器信号:
| void | textElideModeChanged(Qt::TextElideMode elideMode) |
titleColor : QColor
该属性用于指定绘制标题文本时所用的颜色。
访问函数:
| QColor | titleColor() const |
| void | setTitleColor(QColor color) |
通知信号:
| void | titleColorChanged(QColor color) |
titleFont : QFont
此属性用于指定坐标轴标题的字体。
访问函数:
| QFont | titleFont() const |
| void | setTitleFont(const QFont &font) |
通知信号:
| void | titleFontChanged(const QFont &font) |
titleText : QString
此属性用于存储坐标轴的标题。
默认值为空。坐标轴标题支持 HTML 格式。
访问函数:
| QString | titleText() const |
| void | setTitleText(const QString &title) |
通知信号:
| void | titleTextChanged(const QString &title) |
titleVisible : bool
该属性控制轴标题的可见性。
默认情况下,该值为true 。
访问函数:
| bool | isTitleVisible() const |
| void | setTitleVisible(bool visible = true) |
通知信号:
| void | titleVisibleChanged(bool visible) |
visible : bool
该属性控制坐标轴的可见性。默认情况下,其值为true 。
访问函数:
| bool | isVisible() const |
| void | setVisible(bool visible = true) |
通知信号:
| void | visibleChanged(bool visible) |
成员函数文档
[override virtual noexcept] QAbstractAxis::~QAbstractAxis()
销毁该轴对象。当该轴被添加到图中时,图对象将接管其所有权。
void QAbstractAxis::hide()
将坐标轴、标签和网格线设为不可见。
void QAbstractAxis::setLineVisible(bool visible = true)
用于确定坐标轴线和刻度是否为visible 。
注意: 这是属性lineVisible 的设置 函数。
另请参阅 isLineVisible()。
void QAbstractAxis::setMax(const QVariant &max)
设置轴上显示的最大值。根据实际的轴类型,max 参数将被转换为相应的值类型。如果无法进行转换,则该函数调用不执行任何操作。
void QAbstractAxis::setMin(const QVariant &min)
设置轴上显示的最小值。根据实际的轴类型,min 参数将被转换为相应的值类型。如果无法进行转换,则该函数调用不执行任何操作。
void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)
设置轴上显示的范围。根据实际的轴类型,min 和max 参数将被转换为相应的值类型。如果无法进行转换,则该函数调用不执行任何操作。
void QAbstractAxis::setTitleColor(QColor color)
将绘制标题所用的颜色设置为color 。
注意: 这是属性 `titleColor`的设置 函数。
另请参阅 titleColor()。
void QAbstractAxis::setTitleFont(const QFont &font)
将用于绘制标题的字体设置为font 。
注意: 这是属性titleFont 的设置 函数。
另请参阅 titleFont()。
void QAbstractAxis::setVisible(bool visible = true)
将坐标轴、标签和网格线的可见性设置为visible 。
注意: 这是属性visible 的设置 函数。
另请参阅 isVisible()。
void QAbstractAxis::show()
显示坐标轴、标签和网格线。
QColor QAbstractAxis::titleColor() const
返回用于绘制标题的颜色。
注意: 这是 titleColor 属性的获取器 函数。
另请参阅 setTitleColor()。
QFont QAbstractAxis::titleFont() const
返回用于绘制标题的字体。
注意: 这是 titleFont 属性的获取 函数。
另请参阅 setTitleFont()。
[pure virtual] QAbstractAxis::AxisType QAbstractAxis::type() const
返回轴的类型。
[signal] void QAbstractAxis::update()
当需要更新轴时,会发出此信号。
© 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.