QKeyframeAnimation Class

class Qt3DAnimation::QKeyframeAnimation

A class implementing simple keyframe animation to a QTransform. More...

Header: #include <QKeyframeAnimation>
qmake: QT += 3danimation
Since: Qt 5.9
Instantiated By: KeyframeAnimation
Inherits: Qt3DAnimation::QAbstractAnimation

This class was introduced in Qt 5.9.

Public Types

enum RepeatMode { None, Constant, Repeat }

Public Functions

QKeyframeAnimation(QObject *parent = nullptr)
void addKeyframe(Qt3DCore::QTransform *keyframe)
QVector<Qt3DCore::QTransform *> keyframeList() const
void removeKeyframe(Qt3DCore::QTransform *keyframe)
void setKeyframes(const QVector<Qt3DCore::QTransform *> &keyframes)

Detailed Description

A Qt3DAnimation::QKeyframeAnimation class implements simple keyframe animation that can be used to animate QTransform. The keyframes consists of multiple timed QTransforms, which are interpolated and applied to the target QTransform. QEasingCurve is used between keyframes to control the interpolator. RepeatMode can be set for when the position set to the QKeyframeAnimation is below or above the values defined in the keyframe positions.

Member Type Documentation

enum QKeyframeAnimation::RepeatMode

This enumeration specifies how position values outside keyframe values are handled.

ConstantValueDescription
Qt3DAnimation::QKeyframeAnimation::None0The animation is not applied to the target transform.
Qt3DAnimation::QKeyframeAnimation::Constant1The edge keyframe value is used.
Qt3DAnimation::QKeyframeAnimation::Repeat2The animation is repeated.

Member Function Documentation

QKeyframeAnimation::QKeyframeAnimation(QObject *parent = nullptr)

Constructs an QKeyframeAnimation with parent.

void QKeyframeAnimation::addKeyframe(Qt3DCore::QTransform *keyframe)

Adds new keyframe at the end of the animation. The QTransform can be added to the animation multiple times.

QVector<Qt3DCore::QTransform *> QKeyframeAnimation::keyframeList() const

Returns the list of keyframes.

void QKeyframeAnimation::removeKeyframe(Qt3DCore::QTransform *keyframe)

Removes a keyframe from the animation. If the same QTransform is set as keyframe multiple times, all occurrences are removed.

void QKeyframeAnimation::setKeyframes(const QVector<Qt3DCore::QTransform *> &keyframes)

Sets the keyframes of the animation. Old keyframes are cleared.