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