Qt3DAnimation::QAnimationController Class
class Qt3DAnimation::QAnimationController一个用于动画的控制器类。更多内容...
| 头文件: | #include <qanimationcontroller.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS 3danimation) target_link_libraries(mytarget PRIVATE Qt6::3danimation) |
| qmake: | QT += 3danimation |
| 在 QML 中: | AnimationController |
| 继承自: | QObject |
| 状态: | 技术预览 |
该类处于技术预览阶段,内容可能会发生变更。
属性
|
|
公共函数
| QAnimationController(QObject *parent = nullptr) | |
| int | activeAnimationGroup() const |
| void | addAnimationGroup(Qt3DAnimation::QAnimationGroup *animationGroup) |
| QList<Qt3DAnimation::QAnimationGroup *> | animationGroupList() |
| Qt3DCore::QEntity * | entity() const |
| int | getAnimationIndex(const QString &name) const |
| Qt3DAnimation::QAnimationGroup * | getGroup(int index) const |
| float | position() const |
| float | positionOffset() const |
| float | positionScale() const |
| bool | recursive() const |
| void | removeAnimationGroup(Qt3DAnimation::QAnimationGroup *animationGroup) |
| void | setAnimationGroups(const QList<Qt3DAnimation::QAnimationGroup *> &animationGroups) |
公共槽位
| void | setActiveAnimationGroup(int index) |
| void | setEntity(Qt3DCore::QEntity *entity) |
| void | setPosition(float position) |
| void | setPositionOffset(float offset) |
| void | setPositionScale(float scale) |
| void | setRecursive(bool recursive) |
信号
| void | activeAnimationGroupChanged(int index) |
| void | entityChanged(Qt3DCore::QEntity *entity) |
| void | positionChanged(float position) |
| void | positionOffsetChanged(float offset) |
| void | positionScaleChanged(float scale) |
| void | recursiveChanged(bool recursive) |
详细说明
Qt3DAnimation::QAnimationController 该类用于控制动画的选择和播放。 该类可用于从 Qt3DCore::QEntity 树中查找所有动画,并根据同名动画创建QAnimationGroups 。用户可以通过设置“活动动画”来选择当前由动画控制器控制的动画组。随后,动画位置会在对提供的位置值进行缩放和偏移(使用positionScale 和positionOffset 值)后,传播到该组。
注意: 动画控制器不具备内部计时器,用户需自行负责及时更新位置属性。
属性文档
activeAnimationGroup : int
保存当前活动的动画组。
访问函数:
| int | activeAnimationGroup() const |
| void | setActiveAnimationGroup(int index) |
通知器信号:
| void | activeAnimationGroupChanged(int index) |
entity : Qt3DCore::QEntity*
用于存储用于收集和分组实体动画的实体。如果控制器中已存在动画,则将其清空。
访问函数:
| Qt3DCore::QEntity * | entity() const |
| void | setEntity(Qt3DCore::QEntity *entity) |
通知器信号:
| void | entityChanged(Qt3DCore::QEntity *entity) |
position : float
保存动画的当前位置。设置位置后,系统会通过positionScale/positionOffset 对其进行缩放和偏移,并将结果传递给活动动画组。
访问函数:
| float | position() const |
| void | setPosition(float position) |
通知器信号:
| void | positionChanged(float position) |
positionOffset : float
存储动画的位置偏移量。
访问函数:
| float | positionOffset() const |
| void | setPositionOffset(float offset) |
通知器信号:
| void | positionOffsetChanged(float offset) |
positionScale : float
控制动画的缩放比例。
访问函数:
| float | positionScale() const |
| void | setPositionScale(float scale) |
通知器信号:
| void | positionScaleChanged(float scale) |
recursive : bool
用于控制从实体收集动画时是否递归搜索实体树。如果设置为 true,则也会从该实体的子实体中搜索动画;如果设置为 false,则仅搜索传递给控制器的该实体。
访问函数:
| bool | recursive() const |
| void | setRecursive(bool recursive) |
通知器信号:
| void | recursiveChanged(bool recursive) |
成员函数文档
QAnimationController::QAnimationController(QObject *parent = nullptr)
使用parent 创建一个新的QAnimationController。
void QAnimationController::addAnimationGroup(Qt3DAnimation::QAnimationGroup *animationGroup)
将给定的animationGroup 添加到控制器中。
QList<Qt3DAnimation::QAnimationGroup *> QAnimationController::animationGroupList()
返回控制器当前持有的动画组列表。
[invokable] int QAnimationController::getAnimationIndex(const QString &name) const
返回具有name 的动画的索引。如果未找到名称与给定名称匹配的AnimationGroup ,则返回-1。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] Qt3DAnimation::QAnimationGroup *QAnimationController::getGroup(int index) const
返回具有给定index 的AnimationGroup 。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
void QAnimationController::removeAnimationGroup(Qt3DAnimation::QAnimationGroup *animationGroup)
从控制器中移除指定的animationGroup 。
void QAnimationController::setAnimationGroups(const QList<Qt3DAnimation::QAnimationGroup *> &animationGroups)
设置控制器的新animationGroups 。旧的分组将被清除。
© 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.