Create timeline animations | Qt Creator Documentation

- Qt Creator Documentation
- Create timeline animations
- Qt Creator 19.0.0

Animate property changes ◦ Edit animation curves

# Create timeline animations

You can create timelines and keyframe-based animations for linear interpolation through intermediate values at specified keyframes instead of immediately changing to the target value.

You can also bind the timeline to a property value of a component such as a slider and control the animation this way.

## Add a timeline

Use the timeline and keyframe based editor in the Timeline view to animate the properties of components. The view is empty until you create a timeline.

The following video shows how to insert keyframes for component properties and to animate them in Timeline:

### Create a timeline

To create a timeline to animate a UI component:

1. Go to View > Views > Timeline.
2. Select (Add Timeline) to specify settings for the timeline and running the animation.

3. In Timeline Settings:
   1. In Timeline ID, enter an ID that describes the timeline.
   2. In Start frame, set the first frame of the timeline. Negative values are allowed.
   3. In End frame, set the last frame of the timeline.
4. In Animation Settings:
   1. In Animation ID, enter an ID for the animation.
   2. In Start frame, set the first frame of the animation.
   3. In End frame, set the last frame of the animation.
   4. In Duration, set the length of the animation in milliseconds.

   See the tooltips for the purpose of the optional animation settings.

5. Select Close to close the dialog and save the settings.

You can now set the keyframes for the properties to animate.

### Set keyframe values

When you create a timeline, Qt Quick Designer creates one animation for the timeline. You can create as many animations for a timeline as you want. For example, you can create animations to run just a small section of the timeline or to run the timeline backwards.

To animate components in the Timeline view, you set keyframe values for the property to animate. Qt Quick Designer automatically adds keyframes between two keyframes and sets their values evenly to create, for example, movement or transformation.

To set keyframe values for a component property:

1. In the Navigator view, select the component to animate.
2. In the Properties view, select (Actions) > Insert Keyframe for the property that you want to animate.

3. In Timeline view, select the Per Property Recording button to start recording property changes.

4. Ensure that the playhead is in frame 0 and enter the value of the property in the field next to the property name on the timeline. Select Enter to save the value.
5. Move the playhead to another frame on the timeline and specify the value at that frame. For more information, see Navigate the timeline.
6. When you have specified as many values as you need, select Per Property Recording again to stop recording.

### Create timelines for use in states

You can create more than one timeline to use in states that you add in the States view.

To create a timeline for a second state:

1. Go to Timeline > Timeline Settings.
2. Select to create another timeline.
3. In the table below Animation Settings tab, set the timeline for the state where you want to use it.

### Bind a timeline to a property

When you bind a timeline to a component property, the animation's current frame is controlled by the value of the property.

In this example, you bind the timeline to a slider component.

With a timeline created and keyframe values set:

1. From Components, drag a slider to the 2D or Navigator view.
2. In Navigator, select slider and in Properties, set To to 1000.

   Note: The From and To values of the slider should match the Start Frame and End Frame values of the timeline if you want to control the complete animation with the slider.

3. In the Timeline Settings dialog, select next to the Animation Settings tab to delete the animation. If you have several animations, delete all.
4. In Expression binding, enter `slider.value`.

### Bind animations to states

Bind animations to states to run them when you enter the state.

In the table at the bottom of the Timeline Settings dialog:

1. Double-click the value in Timeline and select the timeline with the animation you want to bind to the state.
2. Double-click the value in Animation and select the animation you want to bind to the state.

To bind a state to a certain keyframe in an animation without running the animation, set the keyframe in Fixed Frame.

## Manage keyframes

### Edit keyframes

To remove all the changes you recorded for a property, right-click the property name on the timeline and select Remove Property.

To add keyframes to the keyframe track of a component at the current position of the playhead, right-click the component name on the timeline and select Add Keyframes at Current Frame.

Keyframes are marked on the timeline by using markers of different colors and shapes, depending on whether they are active or inactive or whether you have applied easing curves to them.

### Edit keyframe values

To fine-tune the value of a keyframe, double-click a keyframe marker or right-click it and select Edit Keyframe in the context menu.

The Edit Keyframe dialog displays the name of the property you are animating and its current value at the frame specified in the Frame. You can change both the keyframe and its value.

### Copy keyframes

You can copy the keyframes from the keyframe track for a component and paste them to the keyframe track of another component.

To copy all keyframes from one track to another:

1. Right-click the component ID and select Copy All Keyframes in the context menu.
2. Right-click the other component ID, and select Paste Keyframes in the context menu.

### Delete keyframes

To delete a keyframe, right-click it and select Delete Keyframe in the context menu.

To delete all keyframes from the selected component, right-click the component name in Timeline and select Delete All Keyframes in the context menu.

## Navigate the timeline

You can navigate the timeline in the following ways:

- Drag the playhead (1) to a frame.
- Click on the ruler (2) to move to a frame.
- Select the Start Frame (Home), Previous Frame (,), NextFrame (.), or End Frame (End) buttons (3), or use the keyboard shortcuts to move to the first, previous, next, or last frame on the timeline.
- Enter the number of a frame in the current keyframe field (4) to move to that frame.
- Select the Previous and Next buttons next to a property name on the timeline (5) to move to the previous or next keyframe for that property.

## Zoom the timeline

Use the slider on the toolbar to set the zooming level in Timeline. Select the and buttons to zoom out of or into the view.

## Set keyframe track color

To change the color of a keyframe track, select Override Color in the context menu, and then select a color in the color picker. To reset the color, select Reset Color.

## View the animation

To preview your animation, do one of the following in the Timeline view:

- Drag the playhead along the timeline.
- Select or Space.

To preview the whole UI, select the run dropdown from the top toolbar, and then select Live Preview, or select Alt + P.

## Animate rotation

To animate components that rotate around a central point, you can use the Item component as a parent for the rotating component. Then create a timeline for the Item, and set the rotation property for the start and end keyframes.

## Animate shapes

You can use the Qt Quick Shapes Design Helpers to animate the following shapes:

- EllipseShape
- RectangleShape
- RegularPolygonShape
- StarShape

See also How to: Add animation, Qt Quick UI design, and Designing Qt Quick UIs.

Animate property changes ◦ Edit animation curves