Creating Timeline Animations
You can create timeline and keyframe based animations for linear interpolation through intermediate values at specified keyframes instead of immediately changing to the target value.
You specify settings for the timeline and for running the animation in the Timeline Settings dialog. The Animation radio button is selected for a timeline animation and the Expression binding radio button for a property animation.
To create a timeline to animate a UI component:
- In the Timeline view, select the (Add Timeline) button to specify settings for the timeline and running the animation in the Timeline Settings dialog.
- In the Timeline ID field, enter an ID that describes the animated component.
- In the Start frame field, set the first frame of the timeline. Negative values are allowed.
- In the End frame field, set the last frame of the timeline.
- In the Animation ID field, enter an ID for the animation.
- Select the Running in Base State check box to run the animation when the base state is applied. Deselect the check box if you want to run the animation when some other state is applied. For more information, see Binding Animations to States.
- In the Start frame field, set the first frame of the animation.
- In the End frame field, set the last frame of the animation.
- In the Duration field, set the length of the animation from the start frame to the end frame. If you set a shorter duration than the number of frames, frames are left out from the end of the animation when viewing it.
- Select the Continuous check box to loop the animation indefinitely.
- In the Loops field, select the number of times to run the animation as a loop. The default number of loops is one, which means that you must restart the animation to see it again
- Select the Ping pong check box to play the animation backwards back to the beginning when it reaches the end.
- In the Finished field, select the state to apply when the animation finishes.
- Select Close to close the dialog and save the settings.
To create additional timelines, select the (Add Timeline) button next to the Timeline Settings tab.
To specify settings for running timeline animations, select the (Add Animation) button next to the Animation Settings tab. For example, you could create settings for running a part of the timeline animation between specified frames or for running the animation backwards from the last frame to the first.
The table at the bottom of the Timeline Settings dialog lists the available states. Double-click the values in the Timeline and Animation column to bind the states to animations. In the Fixed Frame column, you can bind the states that don't have animations to fixed frames.
To animate components in the Timeline view, move to a frame on the timeline and specify changes in the values of a property. Qt Design Studio automatically adds keyframes between two keyframes and sets their values evenly to create an appearance of movement or transformation.
You can insert keyframes for all the properties of all the components that you want to animate first, and then record the changes in their values by selecting the (Per Property Recording) button for one property at a time. For example, you can hide and show components by turning their visibility off and on or by setting their opacity to 0 or 1.
You can also select the Auto Key (K) button (or press K) to record changes in property values, but you need to be more careful about which property values you are changing to avoid surprises.
To record the changes of property values:
- In the Navigator view, select the component to animate.
- In the Properties view, select (Actions) > Insert Keyframe for the property that you want to animate.
- In the Timeline view, select the Per Property Recording button to start recording property changes.
- Check 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. Press Enter to save the value.
- Move the playhead to another frame on the timeline and specify the value at that frame. For more information, see Navigating in Timeline.
- When you have specified as many values as you need, select Per Property Recording again to stop recording.
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, select Add Keyframes at Current Frame.
To fine-tune the value of a keyframe, double-click a keyframe marker or 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 field. You can change both the keyframe and its value.
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 one, first right-click the component ID and select Copy All Keyframes in the context menu. Then right-click the other component ID, and select Paste Keyframes in the context menu.
To delete the selected keyframe, select Delete Keyframe in the context menu.
To delete all keyframes from the selected component, select Delete All Keyframes in the context menu.
You can view the animation on the canvas by moving the playhead along the timeline.
To preview the animation, select the Play (Space) button or press Space. To preview the whole UI, select the (Show Live Preview) button on the canvas toolbar or press Alt+P.
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.
You can use the Qt Quick Studio Components to animate the following shapes:
Available under certain Qt licenses.
Find out more.