QKeyframeAnimation Class | Qt 3D 5.12.11

- Qt 5.12
- Qt 3D
- C++ Classes
- QKeyframeAnimation
- Qt 5.12.11 Reference Documentation

# QKeyframeAnimation 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

- List of all members, including inherited members
- Obsolete members

## Public Types

enum | RepeatMode { None, Constant, Repeat }

## Properties

- easing : QEasingCurve
- endMode : RepeatMode
- framePositions : QVector<float>

- startMode : RepeatMode
- target : Qt3DCore::QTransform*
- targetName : QString

- 4 properties inherited from Qt3DAnimation::QAbstractAnimation
- 1 property inherited from QObject

## Public Functions

| QKeyframeAnimation(QObject *parent = nullptr)
void | addKeyframe(Qt3DCore::QTransform *keyframe)
QEasingCurve | easing() const
Qt3DAnimation::QKeyframeAnimation::RepeatMode | endMode() const
QVector<float> | framePositions() const
QVector<Qt3DCore::QTransform *> | keyframeList() const
void | removeKeyframe(Qt3DCore::QTransform *keyframe)
void | setKeyframes(const QVector<Qt3DCore::QTransform *> &keyframes)
Qt3DAnimation::QKeyframeAnimation::RepeatMode | startMode() const
Qt3DCore::QTransform * | target() const
QString | targetName() const

- 4 public functions inherited from Qt3DAnimation::QAbstractAnimation
- 31 public functions inherited from QObject

## Public Slots

void | setEasing(const QEasingCurve &easing)
void | setEndMode(Qt3DAnimation::QKeyframeAnimation::RepeatMode mode)
void | setFramePositions(const QVector<float> &positions)
void | setStartMode(Qt3DAnimation::QKeyframeAnimation::RepeatMode mode)
void | setTarget(Qt3DCore::QTransform *target)
void | setTargetName(const QString &name)

- 2 public slots inherited from Qt3DAnimation::QAbstractAnimation
- 1 public slot inherited from QObject

## Signals

void | easingChanged(const QEasingCurve &easing)
void | endModeChanged(QKeyframeAnimation::RepeatMode endMode)
void | framePositionsChanged(const QVector<float> &positions)
void | startModeChanged(QKeyframeAnimation::RepeatMode startMode)
void | targetChanged(Qt3DCore::QTransform *target)
void | targetNameChanged(const QString &name)

- 3 signals inherited from Qt3DAnimation::QAbstractAnimation
- 2 signals inherited from QObject

## Static Public Members

const QMetaObject | staticMetaObject

- 9 static public members inherited from QObject

### Additional Inherited Members

- 1 protected function inherited from Qt3DAnimation::QAbstractAnimation
- 9 protected functions inherited from QObject

## Detailed Description

A class implementing simple keyframe animation to a QTransform.

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.

Constant | Value | Description
--- | --- | ---
`Qt3DAnimation::QKeyframeAnimation::None` | `0` | The animation is not applied to the target transform.
`Qt3DAnimation::QKeyframeAnimation::Constant` | `1` | The edge keyframe value is used.
`Qt3DAnimation::QKeyframeAnimation::Repeat` | `2` | The animation is repeated.

## Property Documentation

### easing : QEasingCurve

Holds the easing curve of the interpolator between keyframes.

Access functions:

QEasingCurve | easing() const
void | setEasing(const QEasingCurve &easing)

Notifier signal:

void | easingChanged(const QEasingCurve &easing)

### endMode : RepeatMode

Holds the repeat mode for the position values greater than the last frame position.

Access functions:

Qt3DAnimation::QKeyframeAnimation::RepeatMode | endMode() const
void | setEndMode(Qt3DAnimation::QKeyframeAnimation::RepeatMode mode)

Notifier signal:

void | endModeChanged(QKeyframeAnimation::RepeatMode endMode)

### framePositions : QVector<float>

Holds the positions of the keyframes. Each position in the list specifies the position of the corresponding keyframe with the same index. The values must be in an ascending order. Values can be positive or negative and do not have any predefined unit.

Access functions:

QVector<float> | framePositions() const
void | setFramePositions(const QVector<float> &positions)

Notifier signal:

void | framePositionsChanged(const QVector<float> &positions)

### startMode : RepeatMode

Holds the repeat mode for the position values less than the first frame position.

Access functions:

Qt3DAnimation::QKeyframeAnimation::RepeatMode | startMode() const
void | setStartMode(Qt3DAnimation::QKeyframeAnimation::RepeatMode mode)

Notifier signal:

void | startModeChanged(QKeyframeAnimation::RepeatMode startMode)

### target : Qt3DCore::QTransform*

Holds the target QTransform the animation is applied to.

Access functions:

Qt3DCore::QTransform * | target() const
void | setTarget(Qt3DCore::QTransform *target)

Notifier signal:

void | targetChanged(Qt3DCore::QTransform *target)

### targetName : QString

Holds the name of the target transform. This is a convenience property making it easier to match the target transform to the keyframe animation. The name is usually same as the name of the parent entity of the target transform, but does not have to be.

Access functions:

QString | targetName() const
void | setTargetName(const QString &name)

Notifier signal:

void | targetNameChanged(const QString &name)

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