本页内容

Qt3DInput::QAxisAccumulator Class

class Qt3DInput::QAxisAccumulator

QAxisAccumulator 处理来自QAxis 的速度或加速度数据。更多内容...

标题: #include <qaxisaccumulator.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3dinput)
target_link_libraries(mytarget PRIVATE Qt6::3dinput)
qmake: QT += 3dinput
在 QML 中: AxisAccumulator
继承自: Qt3DCore::QComponent
状态: 已弃用

该类已弃用。我们强烈建议在新代码中不要使用它。

公共类型

enum SourceAxisType { Velocity, Acceleration }

属性

公共函数

QAxisAccumulator(Qt3DCore::QNode *parent = nullptr)
float scale() const
Qt3DInput::QAxis *sourceAxis() const
Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType() const
float value() const
float velocity() const

公共槽位

void setScale(float scale)
void setSourceAxis(Qt3DInput::QAxis *sourceAxis)
void setSourceAxisType(Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType)

信号

void scaleChanged(float scale)
void sourceAxisChanged(Qt3DInput::QAxis *sourceAxis)
void sourceAxisTypeChanged(Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType)
void valueChanged(float value)
void velocityChanged(float value)

详细说明

使用parent 构建一个新的QAxisAccumulator实例。

Qt3DInput::QAxis 报告输入设备上轴的当前位置。 当轴返回中性位置时,该轴的值将恢复为 0。通常,需要让轴的输入以其他方式控制变量,例如将Qt3DInput::QAxis 中的值视为速度(对时间的第一次导数)或加速度(对时间的第二次导数)。 这可以通过用户代码或Qt3DLogic::QFrameAction 实现,但这些方法并不理想,因为它们会给主线程增加额外负担,且本质上属于命令式编程。Qt3DInput::QAxisAccumulator 类允许在Qt 3D 后端以声明式方式实现这一常见任务。

成员类型文档

enum QAxisAccumulator::SourceAxisType

常数值
Qt3DInput::QAxisAccumulator::Velocity0
Qt3DInput::QAxisAccumulator::Acceleration1

属性文档

scale : float

存储在累加时用于缩放轴值的倍数。这可以理解为该轴所能控制的最大速度或加速度。

访问函数:

float scale() const
void setScale(float scale)

通知信号:

void scaleChanged(float scale)

sourceAxis : Qt3DInput::QAxis*

保存累加器应对其轴值进行积分的 QAxis。

访问函数:

Qt3DInput::QAxis *sourceAxis() const
void setSourceAxis(Qt3DInput::QAxis *sourceAxis)

通知信号:

void sourceAxisChanged(Qt3DInput::QAxis *sourceAxis)

sourceAxisType : SourceAxisType

保存指定累加器如何处理源轴值的类型。

访问函数:

Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType() const
void setSourceAxisType(Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType)

通知信号:

void sourceAxisTypeChanged(Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType)

[read-only] value : float

返回累积(积分)值。

访问函数:

float value() const

通知信号:

void valueChanged(float value)

[read-only] velocity : float

保存速度值。

如果“sourceAxisType ”(速度源)设置为“Velocity”(速度),则该值即为源轴的数值乘以缩放因子。如果“sourceAxisType ”(速度源)设置为“Acceleration”(加速度),则会将源轴的数值作为加速度来对速度进行积分。

访问函数:

float velocity() const

通知器信号:

void velocityChanged(float value)

成员函数文档

QAxisAccumulator::QAxisAccumulator(Qt3DCore::QNode *parent = nullptr)

创建一个新的 QAxisAccumulator 实例,其父对象为parent 。

float QAxisAccumulator::scale() const

累加时对轴值进行缩放的倍数。这可以理解为该轴所能控制的最大速度或加速度。

返回输入轴值的缩放倍数。

注意: 这是属性 scale 的获取 函数。

另请参阅 setScale()。

[slot] void QAxisAccumulator::setSourceAxis(Qt3DInput::QAxis *sourceAxis)

将累加器应从中接收值的源轴设置为sourceAxis 。这些值的处理方式由sourceAxisType 和scale属性控制。

注意: 此为属性sourceAxis 的设置 函数。

另请参阅 sourceAxis()。

[slot] void QAxisAccumulator::setSourceAxisType(Qt3DInput::QAxisAccumulator::SourceAxisType sourceAxisType)

设置累加器如何处理来自sourceAxisType 的值。

注意: 这是属性sourceAxisType 的设置 函数。

另请参阅 sourceAxisType()。

Qt3DInput::QAxis *QAxisAccumulator::sourceAxis() const

返回累加器应对其轴值进行积分的 QAxis 对象。

注意: 这是源轴(sourceAxis)属性的获取函数 。

另请参阅 setSourceAxis()。

Qt3DInput::QAxisAccumulator::SourceAxisType QAxisAccumulator::sourceAxisType() const

返回累加器如何处理sourceAxis 的值。

注意: 这是 sourceAxisType 属性的获取函数 。

另请参阅 setSourceAxisType()。

float QAxisAccumulator::velocity() const

返回速度。如果“sourceAxisType ”设置为“Velocity”,则该值即为源轴的数值乘以缩放因子。如果“sourceAxisType ”设置为“Acceleration”,则会将源轴的数值作为加速度对速度进行积分。

注意: 这是属性 velocity的获取 函数。

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