本页内容

Qt3DAnimation::QAbstractAnimationClip Class

class Qt3DAnimation::QAbstractAnimationClip

QAbstractAnimationClip 是提供关键帧动画数据的类型的基类。更多内容...

头文件: #include <qabstractanimationclip.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3danimation)
target_link_libraries(mytarget PRIVATE Qt6::3danimation)
qmake: QT += 3danimation
继承自: Qt3DCore::QNode
继承自:

Qt3DAnimation::QAnimationClip 以及Qt3DAnimation::QAnimationClipLoader

状态: 技术预览

该类处于技术预览阶段,内容可能会发生变更。

属性

公共函数

virtual ~QAbstractAnimationClip()
float duration() const

信号

void durationChanged(float duration)

详细说明

要使用Qt 3D 动画模块中的关键帧动画框架,必须向所使用的动画组件提供关键帧动画数据。动画数据由QAbstractAnimationClip的具体子类之一提供:

QAnimationClip 当您希望在应用程序中通过编程方式创建动画数据时,应使用该类。实际数据通过QAnimationClipData 值类型进行设置。

如果您要从文件中加载预渲染的动画数据(例如由美术师创建的),则应使用 `QAnimationClipLoader ` 类并设置其 `source ` 属性。

一旦通过上述方法为动画片段填充了数据,Qt 3D 动画后端将更新其只读的 duration 属性。

动画片段的典型用法是:

auto animator = new QClipAnimator();
auto clip = new QAnimationClipLoader();
clip->setSource(QUrl::fromLocalFile("bounce.json"));
animator->setClip(clip);
animator->setChannelMapper(...);
animator->setRunning(true);

动画片段还被用作动画混合树中的叶节点值:

// Create leaf nodes of blend tree
auto slideClipValue = new QClipBlendValue(
    new QAnimationClipLoader(QUrl::fromLocalFile("slide.json")));
auto bounceClipValue = new QClipBlendValue(
    new QAnimationClipLoader(QUrl::fromLocalFile("bounce.json")));

// Create blend tree inner node
auto additiveNode = new QAdditiveClipBlend();
additiveNode->setBaseClip(slideClipValue);
additiveNode->setAdditiveClip(bounceClipValue);
additiveNode->setAdditiveFactor(0.5f);

// Run the animator
auto animator = new QBlendedClipAnimator();
animator->setBlendTree(additiveNode);
animator->setChannelMapper(...);
animator->setRunning(true);

另请参阅 Qt3DAnimation::QAnimationClip 和Qt3DAnimation::QAnimationClipLoader 。

属性文档

[read-only] duration : float

存储动画片段的时长(单位:秒)。当通过某个具体子类将动画数据提供给Qt 3D 时,该值会随之更新。

访问函数:

float duration() const

通知器信号:

void durationChanged(float duration)

成员函数文档

[virtual noexcept] QAbstractAnimationClip::~QAbstractAnimationClip()

删除此动画片段。

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