Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
topic.qdoc
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qtquick-statesanimations-topic.html
6\title Important Concepts in Qt Quick - States, Transitions and Animations
7\brief Description of the concepts of states, transitions and animations in Qt Quick
8
9In any modern user-interface, transitioning between states and animating
10the user-interface is highly beneficial. These are first-class concepts in
11Qt Quick.
12
13This page describes the concept of states, state transitions, and property
14animations. It details which concepts are important and why, and how those
15concepts interrelate. It also provides links to in-depth detail about the QML
16types that Qt Quick provides to implement those concepts.
17
18\section1 States
19
20The state of a particular visual item is the set of information which describes
21how and where the individual component parts of the visual item are displayed
22within it, and all the data associated with that state. Most visual items in a
23user-interface will have a limited number of states, each with well-defined
24properties.
25
26For example, an element in a list may be either selected or not, and if
27selected, it may either be the currently active single selection or it may be
28part of a selection group.
29
30Each of those states may have certain associated visual appearance (neutral,
31highlighted, expanded, and so forth).
32
33Qt Quick provides a \c{State} type with properties which define its semantics
34and can be used to trigger behavior or animations. See the documentation about
35\l{qtquick-statesanimations-states.html}{Qt Quick States} for more
36information.
37
38\section1 Transitions
39
40When a visual item transitions from one state to another, the appearance of
41that item will change. A transition is an "edge" between two states. It may
42trigger other events to occur, as other parts of the application may have
43behavior which is triggered when a certain state is entered or left.
44
45Qt Quick provides the \c{Transition} type which has properties which define
46what will occur when the application changes from one state to another. See
47the documentation on
48\l{qtquick-statesanimations-animations.html#transitions-during-state-changes}
49{Transitions during State Changes} for more information about transitions.
50
51\section1 Animations
52
53When transitioning between states, a fluid animation can be used to aid the
54user during the transition. Abrupt and unexpected changes to the visual
55canvas result in a suboptimal user-experience and should be avoided.
56
57If an element in a list becomes selected, the color change (from neutral to
58highlighted) can be animated. If the position of the element in the list is
59changed, it can be moved in an fluidly animated fashion so that the eye of the
60user can track the change.
61
62These types of animations are supported in Qt Quick through various animation
63and transition types. See the documentation on
64\l{qtquick-statesanimations-animations.html}
65{Animations and Transitions In Qt Quick} for information about these types
66and how to use them.
67
68
69\section1 Animating Property Assignments
70
71Animations are not only related to states and transitions between states. For
72example, an animation might be triggered by other events, which are not
73associated with a distinct state.
74
75It is often beneficial to always animate changes to certain properties of
76visual items, regardless of the cause of the change (for example, opacity
77effects). Qt Quick provides the \l Behavior type which allows the client to
78specify animation behavior for changes to properties. The \l Behavior type
79is an example of a QML object
80\l{qtqml-cppintegration-definetypes.html#property-modifier-types}
81{property modifier}.
82
83Please see the documentation about
84\l{qtquick-statesanimations-animations.html#default-animation-as-behaviors}
85{default property animations} for more information about using the \l Behavior
86type to provide default property change animations.
87
88It is important to note, that using default property animations (via the
89\l Behavior type) in combination with state-transition animations can sometimes
90result in undefined behavior occurring. Please see the documentation about
91\l{qtquick-statesanimations-behaviors.html}
92{using Qt Quick Behaviors with States} for more information about this topic.
93
94\section1 Animators
95
96The \l Animator types are a special type of animation which bypass
97the QML objects and operate directly on the primitives in the
98\l {Qt Quick Scene Graph}{scene graph}. This has the benefit that
99the Animator based animations can be run on the scene graph's rendering thread
100(when applicable) and can continue to animate even when UI is otherwise
101blocked.
102
103Qt Quick provides the following Animator types:
104\list
105\li \l {XAnimator} - Animates the horizontal position of an \l {Item}.
106\li \l {YAnimator} - Animates the vertical position of an \l {Item}.
107\li \l {ScaleAnimator} - Animates the scale factor of an \l {Item}.
108\li \l {RotationAnimator} - Animates the rotation of an \l {Item}.
109\li \l {OpacityAnimator} - Animates the opacity of an \l {Item}.
110\li \l {UniformAnimator} - Animates a uniform in a \l {ShaderEffect}.
111\endlist
112
113\section1 Animated Sprites
114
115The concept of animated sprites is separate to the concept of animations as
116used elsewhere on this page. If you want to create or use an animated image
117or sprite, please see the documentation about
118\l{qtquick-effects-sprites.html}{sprite animations}.
119
120*/