QValue3DAxisFormatter Class
QValue3DAxisFormatter 类是 3D 值轴格式化器的基类。更多内容...
| 头文件: | #include <QValue3DAxisFormatter> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Graphs) target_link_libraries(mytarget PRIVATE Qt6::Graphs) |
| qmake: | QT += graphs |
| 在 QML 中: | Value3DAxisFormatter |
| 继承自: | QObject |
| 被继承类: |
- 所有成员列表(包括继承的成员)
- QValue3DAxisFormatter 属于Qt Graphs 的3D C++ 类库。
公共函数
| 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 ©) |
| 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 |
另请参阅 QValue3DAxis 和QLogValue3DAxisFormatter 。
成员函数文档
[explicit] QValue3DAxisFormatter::QValue3DAxisFormatter(QObject *parent = nullptr)
使用可选的父对象parent 构建一个新的值 3D 轴格式化器。
[override virtual noexcept] QValue3DAxisFormatter::~QValue3DAxisFormatter()
删除 3D 轴格式化程序的值。
[protected] bool QValue3DAxisFormatter::allowNegatives() const
如果负值是父轴的有效值,则返回true 。默认实现始终返回true 。
另请参阅 setAllowNegatives()。
[protected] bool QValue3DAxisFormatter::allowZero() const
如果零是父轴的有效值,则返回true 。默认实现始终返回true 。
另请参阅 setAllowZero()。
[protected] QValue3DAxis *QValue3DAxisFormatter::axis() const
返回父轴。为在使用多线程渲染器的环境中保持线程安全,必须仅在recalculate()方法中访问父轴。
另请参阅 recalculate()。
[virtual protected] QValue3DAxisFormatter *QValue3DAxisFormatter::createNewInstance() const
创建一个新的空值 3D 轴格式化器。必须在子类中重新实现。
返回新的格式化器。渲染器使用此方法将格式化器的副本缓存起来。新副本的所有权将转移给调用方。
[protected] QList<float> QValue3DAxisFormatter::gridPositions() &&
按值返回一个标准化网格线位置数组。数组的默认大小等于父轴的段数加一,但recalculate() 方法的子类实现可能会以其他方式调整数组大小。
另请参阅 QValue3DAxis::segmentCount 和recalculate()。
[protected] const QList<float> &QValue3DAxisFormatter::gridPositions() const &
返回对归一化网格线位置数组的引用。数组的默认大小等于父轴的段数加一,但recalculate() 方法的子类实现可能会以其他方式调整该数组的大小。
另请参阅 QValue3DAxis::segmentCount 和recalculate()。
[protected] QList<float> QValue3DAxisFormatter::labelPositions() &&
返回一个按值归一化的标签位置数组。默认数组大小等于父轴的区段数加一,但recalculate()方法的子类实现可能会以其他方式调整数组大小。默认情况下,索引为零的标签对应于该轴的最小值。
另请参阅 QValue3DAxis::segmentCount 、QAbstract3DAxis::labels 以及recalculate()。
[protected] const QList<float> &QValue3DAxisFormatter::labelPositions() const &
返回对归一化标签位置数组的引用。默认数组大小等于父轴的段数加一,但recalculate()方法的子类实现可能会以其他方式调整数组大小。默认情况下,索引为零的标签对应于该轴的最小值。
另请参阅 QValue3DAxis::segmentCount 、QAbstract3DAxis::labels 和recalculate()。
[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)
将此格式化器标记为“已修改”,从而促使渲染器在下次渲染器同步时生成其缓存的新副本。每当格式化器发生影响已解析值的变更时,子类都应调用此方法。如果该变更需要重新生成父轴标签字符串,请将labelsChange 设置为true 。
[virtual protected] void QValue3DAxisFormatter::populateCopy(QValue3DAxisFormatter ©)
将使用此格式化器解析位置、值和字符串所需的所有值复制到格式化器的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)
如果allow 的值为true ,则允许父轴具有负值。
另请参阅 allowNegatives()。
[protected] void QValue3DAxisFormatter::setAllowZero(bool allow)
当allow 为true 时,允许父轴的值为零。
另请参阅 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)
返回使用指定的value 和format 格式化的标签字符串。
如果为QValue3DAxis::labelFormat 属性指定的默认格式化规则不够用,请在子类中重写此方法,以根据给定的value 解析格式化字符串。
另请参阅 recalculate()、labelStrings() 和QValue3DAxis::labelFormat 。
[protected] QList<float> QValue3DAxisFormatter::subGridPositions() &&
按值返回一个包含归一化子网格线位置的数组。默认数组大小等于父轴的段数乘以父轴的子段数再减一,但recalculate()方法的子类实现可能会以其他方式调整数组大小。
另请参阅 setSubGridPositions()、QValue3DAxis::segmentCount 、QValue3DAxis::subSegmentCount 以及recalculate()。
[protected] const QList<float> &QValue3DAxisFormatter::subGridPositions() const &
返回对归一化子网格线位置数组的引用。默认数组大小等于父轴的段数乘以父轴的子段数再减一,但recalculate()方法的子类实现可能会以其他方式调整数组大小。
另请参阅 QValue3DAxis::segmentCount 、QValue3DAxis::subSegmentCount 以及recalculate()。
[virtual protected] float QValue3DAxisFormatter::valueAt(float position) const
返回该轴上归一化坐标position 处的值。position 的值应介于0.0 (最小值)和1.0 (最大值)之间(含两端),以获得位于父轴范围内的值。
如果无法通过父轴最小值和最大值之间的线性插值来确定该值,请重写此方法。
另请参阅 recalculate() 和positionAt()。
© 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.