51 |
51 |
52 QT_BEGIN_NAMESPACE |
52 QT_BEGIN_NAMESPACE |
53 |
53 |
54 /*! |
54 /*! |
55 \qmlclass Transition QDeclarativeTransition |
55 \qmlclass Transition QDeclarativeTransition |
|
56 \ingroup qml-animation-transition |
56 \since 4.7 |
57 \since 4.7 |
57 \brief The Transition element defines animated transitions that occur on state changes. |
58 \brief The Transition element defines animated transitions that occur on state changes. |
58 |
59 |
59 A Transition defines the animations to be applied when a \l State change occurs. |
60 A Transition defines the animations to be applied when a \l State change occurs. |
60 |
61 |
61 For example, the following \l Rectangle has two states: the default state, and |
62 For example, the following \l Rectangle has two states: the default state, and |
62 an added "moved" state. In the "moved state, the rectangle's position changes |
63 an added "moved" state. In the "moved state, the rectangle's position changes |
63 to (50, 50). The added \l Transition specifies that when the rectangle |
64 to (50, 50). The added Transition specifies that when the rectangle |
64 changes between the default and the "moved" state, any changes |
65 changes between the default and the "moved" state, any changes |
65 to the \c x and \c y properties should be animated, using an \c Easing.InOutQuad. |
66 to the \c x and \c y properties should be animated, using an \c Easing.InOutQuad. |
66 |
67 |
67 \snippet doc/src/snippets/declarative/transition.qml 0 |
68 \snippet doc/src/snippets/declarative/transition.qml 0 |
68 |
69 |
69 To specify multiple transitions, specify \l Item::transitions as a list: |
70 Notice the example does not require \l{PropertyAnimation::}{to} and |
|
71 \l{PropertyAnimation::}{from} values for the NumberAnimation. As a convenience, |
|
72 these properties are automatically set to the values of \c x and \c y before |
|
73 and after the state change; the \c from values are provided by |
|
74 the current values of \c x and \c y, and the \c to values are provided by |
|
75 the PropertyChanges object. If you wish, you can provide \l{PropertyAnimation::}{to} and |
|
76 \l{PropertyAnimation::}{from} values anyway to override the default values. |
|
77 |
|
78 By default, a Transition's animations are applied for any state change in the |
|
79 parent item. The Transition \l {Transition::}{from} and \l {Transition::}{to} |
|
80 values can be set to restrict the animations to only be applied when changing |
|
81 from one particular state to another. |
|
82 |
|
83 To define multiple transitions, specify \l Item::transitions as a list: |
70 |
84 |
71 \qml |
85 \qml |
72 Item { |
86 Item { |
73 ... |
87 ... |
74 transitions: [ |
88 transitions: [ |
75 Transition { ... } |
89 Transition { ... }, |
76 Transition { ... } |
90 Transition { ... } |
77 ] |
91 ] |
78 } |
92 } |
79 \endqml |
93 \endqml |
80 |
94 |
81 \sa {declarative/animation/states}{states example}, {qmlstates}{States}, {state-transitions}{Transitions}, {QtDeclarative} |
95 If a state change has a Transition that matches the same property as a |
82 */ |
96 \l Behavior, the Transition animation overrides the \l Behavior for that |
83 |
97 state change. |
84 /*! |
98 |
85 \internal |
99 \sa {QML Animation}, {declarative/animation/states}{states example}, {qmlstates}{States}, {QtDeclarative} |
86 \class QDeclarativeTransition |
|
87 \brief The QDeclarativeTransition class allows you to define animated transitions that occur on state changes. |
|
88 */ |
100 */ |
89 |
101 |
90 //ParallelAnimationWrapper allows us to do a "callback" when the animation finishes, rather than connecting |
102 //ParallelAnimationWrapper allows us to do a "callback" when the animation finishes, rather than connecting |
91 //and disconnecting signals and slots frequently |
103 //and disconnecting signals and slots frequently |
92 class ParallelAnimationWrapper : public QParallelAnimationGroup |
104 class ParallelAnimationWrapper : public QParallelAnimationGroup |