QValue3DAxisFormatter Class
QValue3DAxisFormatter 类是值轴格式化器的基类。更多内容...
| 头文件: | #include <QValue3DAxisFormatter> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS DataVisualization) target_link_libraries(mytarget PRIVATE Qt6::DataVisualization) |
| qmake: | QT += datavisualization |
| 自: | QtDataVisualization 1.1 |
| 在 QML 中: | ValueAxis3DFormatter |
| 继承自: | QObject |
| 被继承自: | |
| 状态: | 已弃用 |
该类已弃用。我们强烈建议不要在新代码中使用它。
公共函数
| QValue3DAxisFormatter(QObject *parent = nullptr) | |
| virtual | ~QValue3DAxisFormatter() |
受保护函数
| bool | allowNegatives() const |
| bool | allowZero() const |
| QValue3DAxis * | axis() const |
| virtual QValue3DAxisFormatter * | createNewInstance() const |
| QList<float> & | gridPositions() const |
| QList<float> & | labelPositions() const |
| QStringList & | labelStrings() const |
| QLocale | locale() const |
| void | markDirty(bool labelsChange = false) |
| virtual void | populateCopy(QValue3DAxisFormatter ©) const |
| virtual float | positionAt(float value) const |
| virtual void | recalculate() |
| void | setAllowNegatives(bool allow) |
| void | setAllowZero(bool allow) |
| void | setLocale(const QLocale &locale) |
| virtual QString | stringForValue(qreal value, const QString &format) const |
| QList<float> & | subGridPositions() const |
| virtual float | valueAt(float position) const |
另请参阅 QValue3DAxis 和QLogValue3DAxisFormatter 。
成员函数文档
[explicit] QValue3DAxisFormatter::QValue3DAxisFormatter(QObject *parent = nullptr)
使用可选的父级parent 构建一个新的值型3D轴格式化器。
[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() const
返回对归一化网格线位置数组的引用。数组的默认大小等于父轴的段数加一,但recalculate()方法的子类实现可能会以其他方式调整数组大小。这些值应在0.0 (最小值)和1.0 (最大值)之间(包含两端)。
另请参阅 QValue3DAxis::segmentCount 和recalculate()。
[protected] QList<float> &QValue3DAxisFormatter::labelPositions() const
返回对归一化标签位置数组的引用。默认数组大小等于父轴的段数加一,但recalculate()方法的子类实现可能会以其他方式调整数组大小。 数值应在0.0 (最小值)和1.0 (最大值)之间(包含两端)。默认情况下,索引为零的标签对应于该轴的最小值。
另请参阅 QValue3DAxis::segmentCount 、QAbstract3DAxis::labels 和recalculate()。
[protected] 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 ©) const
将使用此格式化器解析位置、值和字符串所需的所有值复制到格式化器的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::setLocale(const QLocale &locale)
设置此格式化器所使用的locale 。当父轴被设为图的活动轴、轴格式化器被设为附属于该图的轴,或者图的区域设置发生变化时,图会自动将格式化器的区域设置设为图的区域设置。
另请参阅 locale() 和QAbstract3DGraph::locale 。
[virtual protected] QString QValue3DAxisFormatter::stringForValue(qreal value, const QString &format) const
返回使用指定的value 和format 格式化的标签字符串。
如果为QValue3DAxis::labelFormat 属性指定的默认格式化规则不够用,请在子类中重写此方法,以根据给定的value 解析格式化后的字符串。
另请参阅 recalculate()、labelStrings() 以及QValue3DAxis::labelFormat 。
[protected] QList<float> &QValue3DAxisFormatter::subGridPositions() const
返回一个指向归一化子网格线位置数组的引用。默认数组大小等于父轴的段数乘以父轴的子段数再减一,但recalculate() 方法的子类实现可能会以其他方式调整数组大小。 数值应在0.0 (最小值)和1.0 (最大值)之间(包含两端)。
另请参阅 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.