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
\title Animations
6
\keyword Use case - Animations In QML
7
\brief Example of how to include animations in QML applications
8
9
\l {Qt Quick} provides the ability to animate properties. Animating properties
10
allows property values to move through intermediate values instead of
11
immediately changing to the target value. To animate the position of an item,
12
you can animate the properties that control the item's position, x and y for
13
example, so that the item's position changes each frame on the way to the
14
target position.
15
16
\section1 Fluid UIs
17
18
QML was designed to facilitate the creation of fluid UIs. These are user
19
interfaces where the UI components animate instead of appearing, disappearing,
20
or jumping abruptly. Qt Quick provides two simple ways to have UI components
21
move with animation instead of instantly appearing at their new location.
22
23
\section2 States and transitions
24
25
Qt Quick allows you to declare various UI states in \l State objects. These
26
states are comprised of property changes from a base state, and can be a useful
27
way of organizing your UI logic. Transitions are objects you can associate with
28
an item to define how its properties will animate when they change due to a
29
state change.
30
31
States and transitions for an item can be declared with the \l Item::states and
32
\l Item::transitions properties. States are declared inside the states list
33
property of an item, usually the root item of the component. Transitions
34
defined on the same item are used to animate the changes in the state. Here is
35
an example.
36
37
\snippet qmlapp/usecases/animations.qml states
38
39
\section2 Animating property changes.
40
41
Behaviors can be used to specify an animation for a property to use when it
42
changes. This is then applied to all changes, regardless of their source. The
43
following example animates a button moving around the screen using behaviors.
44
45
\snippet qmlapp/usecases/animations.qml behave
46
47
\section1 Other animations
48
49
Not all animations have to be tied to a specific property or state. You can
50
also create animations more generally, and specify target items and properties
51
inside the animation. Here are some examples of different ways to do this:
52
53
\snippet qmlapp/usecases/animations.qml constant
54
\snippet qmlapp/usecases/animations.qml scripted
55
\image qmlapp/qml-uses-animation.png
56
57
More information about animations can be found on the
58
\l{Important Concepts in Qt Quick - States, Transitions and Animations} page.
59
60
*/
qtdeclarative
src
quick
doc
src
getting-started
animations.qdoc
Generated on
for Qt by
1.14.0