QValue3DAxisFormatter Class

QValue3DAxisFormatter 类是 3D 值轴格式化器的基类。更多

Header: #include <QValue3DAxisFormatter>
CMake: find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)
qmake: QT += graphs
在 QML 中: Value3DAxisFormatter
继承: QObject
继承于:

QLogValue3DAxisFormatter

公共函数

QValue3DAxisFormatter(QObject *parent = nullptr)
virtual ~QValue3DAxisFormatter() override

保护函数

bool allowNegatives() const
bool allowZero() const
QValue3DAxis *axis() const
virtual QValue3DAxisFormatter *createNewInstance() const
QList<float> gridPositions() &&
const QList<float> &gridPositions() const &
QList<float> labelPositions() &&
const QList<float> &labelPositions() const &
QStringList labelStrings() &&
const QStringList &labelStrings() const &
QLocale locale() const
void markDirty(bool labelsChange = false)
virtual void populateCopy(QValue3DAxisFormatter &copy)
virtual float positionAt(float value) const
virtual void recalculate()
void setAllowNegatives(bool allow)
void setAllowZero(bool allow)
void setGridPoitions(QList<float> gridPositions)
void setLabelStrings(QStringList labelStrings)
void setLocale(const QLocale &locale)
void setSubGridPositions(QList<float> subGridPositions)
void setlabelPositions(QList<float> labelPositions)
virtual QString stringForValue(qreal value, const QString &format)
QList<float> subGridPositions() &&
const QList<float> &subGridPositions() const &
virtual float valueAt(float position) const

详细描述

该类为线性值 3D 轴提供格式化规则。如果您想实现自定义值轴,可对其进行子类化。

除构造函数和析构函数外,基类没有公共 API。该类仅供内部使用。不过,子类可以根据需要实现公共属性。

另请参阅 QValue3DAxisQLogValue3DAxisFormatter

成员函数文档

[explicit] QValue3DAxisFormatter::QValue3DAxisFormatter(QObject *parent = nullptr)

使用可选的父parent 构建一个新的三维坐标轴格式值。

[override virtual noexcept] QValue3DAxisFormatter::~QValue3DAxisFormatter()

删除 3D 轴格式化值。

[protected] bool QValue3DAxisFormatter::allowNegatives() const

如果父坐标轴的有效值为负值,则返回true 。默认实现总是返回true

另请参见 setAllowNegatives()。

[protected] bool QValue3DAxisFormatter::allowZero() const

如果 0 是父坐标轴的有效值,则返回true 。默认实现总是返回true

另请参见 setAllowZero().

[protected] QValue3DAxis *QValue3DAxisFormatter::axis() const

返回父轴。父轴只能在recalculate() 方法中访问,以便在使用线程渲染器的环境中保持线程安全。

另请参见 recalculate()。

[virtual protected] QValue3DAxisFormatter *QValue3DAxisFormatter::createNewInstance() const

创建一个新的空值 3D 轴格式器。必须在子类中重新实现。

返回新的格式器。呈现器使用此方法缓存格式器的副本。新副本的所有权将转移给调用者。

[protected] QList<float> QValue3DAxisFormatter::gridPositions() &&

按值返回归一化网格线位置数组。默认数组大小等于父轴的线段数加一,但recalculate() 方法的子类实现可能会以不同方式调整数组大小。

另请参见 QValue3DAxis::segmentCountrecalculate()。

[protected] const QList<float> &QValue3DAxisFormatter::gridPositions() const &

返回归一化网格线位置数组的引用。默认数组大小等于父轴的线段数加一,但recalculate() 方法的子类实现可能会以不同方式调整数组大小。

另请参见 QValue3DAxis::segmentCountrecalculate()。

[protected] QList<float> QValue3DAxisFormatter::labelPositions() &&

按值返回归一化标签位置数组。默认数组大小等于父轴的线段数加一,但recalculate() 方法的子类实现可能会以不同方式调整数组大小。默认情况下,索引为 0 的标签对应于轴的最小值。

另请参见 QValue3DAxis::segmentCountQAbstract3DAxis::labelsrecalculate()。

[protected] const QList<float> &QValue3DAxisFormatter::labelPositions() const &

返回归一化标签位置数组的引用。默认数组大小等于父轴的线段数加一,但recalculate() 方法的子类实现可能会以不同方式调整数组大小。默认情况下,位于索引 0 处的标签对应于轴的最小值。

另请参阅 QValue3DAxis::segmentCountQAbstract3DAxis::labelsrecalculate()。

[protected] QStringList QValue3DAxisFormatter::labelStrings() &&

按值返回包含格式标签字符串的字符串列表。

另请参阅 setLabelStrings() 和labelPositions()。

[protected] const QStringList &QValue3DAxisFormatter::labelStrings() const &

返回包含格式化器标签字符串的字符串列表的引用。

另请参见 labelPositions()。

[protected] QLocale QValue3DAxisFormatter::locale() const

返回格式化器当前使用的本地语言。

另请参阅 setLocale()。

[protected] void QValue3DAxisFormatter::markDirty(bool labelsChange = false)

将此格式器标记为 "脏"(dirty),提示呈现器在下一次呈现器同步时创建新的缓存副本。每当格式器的更改影响到解析值时,子类都应调用此方法。如果更改需要重新生成父轴标签字符串,请将labelsChange 设置为true

[virtual protected] void QValue3DAxisFormatter::populateCopy(QValue3DAxisFormatter &copy)

将使用该格式器解析位置、值和字符串所需的所有值复制到格式器的copy 。在子类中重新实现此方法时,请在某处调用超类的版本。呈现器使用此方法缓存格式器的副本。

返回新副本。新副本的所有权将转移给调用者。

[virtual protected] float QValue3DAxisFormatter::positionAt(float value) const

为给定的value 返回沿坐标轴的归一化位置。如果该值在父坐标轴范围内,则返回值应介于0.0 (最小值)和1.0 (最大值)之间(含)。

如果无法通过父轴最小值和最大值之间的线性插值解决位置问题,则重新执行此方法。

另请参见 recalculate() 和valueAt()。

[virtual protected] void QValue3DAxisFormatter::recalculate()

调整标签和网格线位置数组以及标签字符串数组的大小并填充其内容,同时计算将值映射到其位置所需的任何值。父轴可以在此函数中访问。

如果默认数组内容不合适,必须在子类中重新实现该方法。

请参见gridPositions()、subGridPositions()、labelPositions() 和labelStrings() 方法,了解有关需要调整大小和填充的数组的文档。

另请参见 gridPositions()、subGridPositions()、labelPositions()、labelStrings() 和axis()。

[protected] void QValue3DAxisFormatter::setAllowNegatives(bool allow)

如果allowtrue ,则允许父轴具有负值。

另请参见 allowNegatives() 。

[protected] void QValue3DAxisFormatter::setAllowZero(bool allow)

如果allowtrue ,则允许父轴的值为零。

另请参见 allowZero() 。

[protected] void QValue3DAxisFormatter::setGridPoitions(QList<float> gridPositions)

设置从gridPositions 开始的新网格位置列表。数值应介于0.0 (最小值)和1.0 (最大值)之间,含首尾两个值。

另请参阅 QValue3DAxis::segmentCount,recalculate() 和gridPositions

[protected] void QValue3DAxisFormatter::setLabelStrings(QStringList labelStrings)

设置来自labelStrings 的新标签字符串列表。数组大小必须等于标签位置数组的大小,索引也对应于标签位置数组。

另请参阅 labelPositions() 和labelStrings()。

[protected] void QValue3DAxisFormatter::setLocale(const QLocale &locale)

设置此格式器使用的locale 。当父坐标轴被设置为图形的活动坐标轴、坐标轴格式化器被设置为附加到图形的坐标轴或图形的区域设置发生变化时,图形会自动将格式化器的区域设置为图形的区域设置。

另请参阅 locale() 和Q3DGraphsWidgetItem::locale

[protected] void QValue3DAxisFormatter::setSubGridPositions(QList<float> subGridPositions)

设置从subGridPositions 开始的新子网格位置列表。这些值应介于0.0 (最小值)和1.0 (最大值)之间,含首尾两个值。

另请参阅 QValue3DAxis::segmentCount,QValue3DAxis::subSegmentCount,recalculate() 和subGridPositions

[protected] void QValue3DAxisFormatter::setlabelPositions(QList<float> labelPositions)

设置从labelPositions 开始的新标签位置列表。这些值应介于0.0 (最小值)和1.0 (最大值)之间,含首尾两个值。

另请参阅 QValue3DAxis::segmentCount,QAbstract3DAxis::labels,recalculate() 和labelPositions() 。

[virtual protected] QString QValue3DAxisFormatter::stringForValue(qreal value, const QString &format)

使用指定的valueformat 返回格式化的标签字符串。

如果为QValue3DAxis::labelFormat 属性指定的默认格式化规则不够充分,可在子类中重新实现此方法,以解析给定value 的格式化字符串。

另请参阅 recalculate()、labelStrings() 和QValue3DAxis::labelFormat

[protected] QList<float> QValue3DAxisFormatter::subGridPositions() &&

按值返回归一化子网格线位置数组。默认数组大小等于父轴的线段数乘以父轴的子线段数减去 1,但recalculate() 方法的子类实现可能会以不同方式调整数组大小。

另请参阅 setSubGridPositions(),QValue3DAxis::segmentCount,QValue3DAxis::subSegmentCount, 和recalculate() 。

[protected] const QList<float> &QValue3DAxisFormatter::subGridPositions() const &

返回归一化子网格线位置数组的引用。默认的数组大小等于父轴的线段数乘以父轴的子线段数减去 1,但recalculate() 方法的子类实现可能会以不同方式调整数组大小。

另请参见 QValue3DAxis::segmentCountQValue3DAxis::subSegmentCountrecalculate()。

[virtual protected] float QValue3DAxisFormatter::valueAt(float position) const

返回坐标轴归一化position 处的值。position 值应介于0.0 (最小值)和1.0 (最大值)之间,以获得父坐标轴范围内的值。

如果无法通过父坐标轴最小值和最大值之间的线性插值解决数值问题,请重新执行此方法。

另请参阅 recalculate() 和positionAt()。

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