Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
animations.qdoc
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3/*!
4\page qtquick-usecase-animations.html
5\meta {keywords} {qmltopic}
6\title Animations
7\keyword Use case - Animations In QML
8\brief Example of how to include animations in QML applications
9
10\l {Qt Quick} provides the ability to animate properties. Animating properties
11allows property values to move through intermediate values instead of
12immediately changing to the target value. To animate the position of an item,
13you can animate the properties that control the item's position, x and y for
14example, so that the item's position changes each frame on the way to the
15target position.
16
17\section1 Fluid UIs
18
19QML was designed to facilitate the creation of fluid UIs. These are user
20interfaces where the UI components animate instead of appearing, disappearing,
21or jumping abruptly. Qt Quick provides two simple ways to have UI components
22move with animation instead of instantly appearing at their new location.
23
24\section2 States and transitions
25
26Qt Quick allows you to declare various UI states in \l State objects. These
27states are comprised of property changes from a base state, and can be a useful
28way of organizing your UI logic. Transitions are objects you can associate with
29an item to define how its properties will animate when they change due to a
30state change.
31
32States and transitions for an item can be declared with the \l Item::states and
33\l Item::transitions properties. States are declared inside the states list
34property of an item, usually the root item of the component. Transitions
35defined on the same item are used to animate the changes in the state. Here is
36an example.
37
38\snippet qmlapp/usecases/animations.qml states
39
40\section2 Animating property changes.
41
42Behaviors can be used to specify an animation for a property to use when it
43changes. This is then applied to all changes, regardless of their source. The
44following example animates a button moving around the screen using behaviors.
45
46\snippet qmlapp/usecases/animations.qml behave
47
48\section1 Other animations
49
50Not all animations have to be tied to a specific property or state. You can
51also create animations more generally, and specify target items and properties
52inside the animation. Here are some examples of different ways to do this:
53
54\snippet qmlapp/usecases/animations.qml constant
55\snippet qmlapp/usecases/animations.qml scripted
56\image qmlapp/qml-uses-animation.png
57
58More information about animations can be found on the
59\l{Important Concepts in Qt Quick - States, Transitions and Animations} page.
60
61*/