aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/qml/propertyaction.qml
blob: 28c2b6e2473ee9c6f95a832464bbf7a262217218 (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) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick

Row {

    //![transition]
    Item {
        width: 400; height: 400

        Rectangle {
            id: rect
            width: 200; height: 100
            color: "red"

            states: State {
                name: "rotated"
                PropertyChanges { target: rect; rotation: 180; transformOrigin: Item.BottomRight }
            }

            transitions: Transition {
                RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise }
            }

            MouseArea {
                anchors.fill: parent
                onClicked: rect.state = "rotated"
            }
        }
    }
    //![transition]

    Item {
        width: 300; height: 300

        Image { id: img; source: "pics/qt.png" }

        //![standalone]
        SequentialAnimation {
            PropertyAction { target: img; property: "opacity"; value: .5 }
            NumberAnimation { target: img; property: "width"; to: 300; duration: 1000 }
            PropertyAction { target: img; property: "opacity"; value: 1 }
        }
        //![standalone]
    }
}