summaryrefslogtreecommitdiffstats
path: root/examples/statemachine/doc/src/states.qdoc
blob: daf29e43fb6f4f6a0452aa564aaa85e3e3a514d5 (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \example animation/states
    \title States Example
    \ingroup examples-qtstatemachine

    \brief The States example shows how to use the Qt state machine to play
    animations.

    The example demonstrates how QStateMachine states can be used to animate
    properties of widgets. There are three states in the application that
    can be sequentially triggered by a button. The button initiates state transitions
    that animate the properties of the application widgets.

    \image states-example.png

    \section1 The \c main() Function

    \snippet animation/states/main.cpp 0

    The widgets are created and added to the QGraphicsScene. The Pixmap class is also
    defined in the example. It extends QGraphicsPixmapItem so that its position can be read
    and written as Qt properties.

    \snippet animation/states/main.cpp 1

    The state machine and the states are created.

    \image states-chart.png

    \snippet animation/states/main.cpp 2

    Each state is assigned the object properties that they will apply.

    \snippet animation/states/main.cpp 3

    The state transitions are created with the trigger of the button click.
    For each property, a QPropertyAnimation is created that interpolates between the
    property values.

    \snippet animation/states/main.cpp 4

    The state machine is started and the \c scene is assigned to a GraphicsView.
*/