aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/src/appdevguide/usecases/animations.qdoc
blob: 3e87bae81dec688af8cbf4b3f7b1116aa5d8cbd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.  Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page qtquick-usecase-animations.html
\title Usecase - Animations In QML
\brief Example of how to include animations in QML applications

QtQuick provides the ability to animate properties. Animating properties allows property values to move through
intermediate values instead of immediately changing to the target value. To animate the position of an item, you can
animate the properties that controle the item's position, x and y for example, so that the item's position 
changes each frame on the way to the target position.

\section1 Fluid UIs

QML was designed to facilitate the creation of fluid UIs. These are user interfaces where the UI elements animate when
they move instead of elements appearing, disappearing, or jumping. Qt Quick provides two simple ways to have UI
elements move with animation instead of instantly appearing at their new location.

\section2 States and Transitions

QtQuick allows you to declare various UI states in \l State objects. These states are comprised of property changes from a
base state, and can be a useful way of organizing your UI logic. Transitions are objects you can associate with an item
to define how its properties will animate when they change due to a state change.

States and transitions for an item can be declared with the \l Item::states and \l Item::transitions properties.
States are declared inside the states list property of an item, usually the root item of the component. Transitions
defined on the same item are used to animate the changes in the state. Here is an example.

\snippet qml/usecases/animations.qml states

\section2 Animating Property Changes.

Behaviors can be used to specify an animation for a property to use when it changes. This is then applied to all
changes, regardless of their source. The following example animates a button moving around the
screen using behaviors.

\snippet qml/usecases/animations.qml behave

\section1 Other Animations

Not all animations have to be tied to a specific property or state. You can also create animations more generally, and
specify target items and properties inside the animation. Here are some examples of different ways to do this:

\snippet qml/usecases/animations.qml constant
\snippet qml/usecases/animations.qml scripted
\image qml-uses-animation.png

More information about animations can be found on the \l{Important Concepts in Qt Quick - States, Transitions and
Animations} page.
*/