summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/states.qml
blob: 7bfb5bdc3d1c5762e396c917f7525051e0e59c60 (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
//![0]
import Qt 4.7

Item {
    id: myItem
    width: 200; height: 200

    Rectangle {
        id: myRect
        width: 100; height: 100
        color: "red"
    }

    states: [
        State {
            name: "moved"
            PropertyChanges {
                target: myRect
                x: 50
                y: 50
            }
        }
    ]

    MouseArea {
        anchors.fill: parent
        onClicked: myItem.state = 'moved'
    }
//![0]

//![transitions]
transitions: [
    Transition {
        NumberAnimation { properties: "x,y"; duration: 500 }
    }
]
//![transitions]

//![1]
}
//![1]