summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/helloworld/tutorial3.qml
blob: d641ebac9853a575690202c3f13b4a0e7b64eac4 (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
47
48
49
50
51
//![0]
import Qt 4.6

Rectangle {
    id: page
    width: 500; height: 200
    color: "lightgray"

    Text {
        id: helloText
        text: "Hello world!"
        font.pointSize: 24; font.bold: true
        y: 30; anchors.horizontalCenter: page.horizontalCenter
        transformOrigin: "Center"

//![1]
        MouseRegion { id: mouseRegion; anchors.fill: parent }
//![1]

//![2]
        states: State {
            name: "down"; when: mouseRegion.pressed == true
            PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" }
        }
//![2]

//![3]
        transitions: Transition {
            from: ""; to: "down"; reversible: true
            ParallelAnimation {
                NumberAnimation { properties: "y,rotation"; duration: 500; easing: "easeInOutQuad" }
                ColorAnimation { property: "color"; duration: 500 }
            }
        }
//![3]
    }

    Grid {
        id: colorPicker
        anchors.bottom: page.bottom
        rows: 2; columns: 3; spacing: 3

        Cell { color: "red"; onClicked: helloText.color = color }
        Cell { color: "green"; onClicked: helloText.color = color }
        Cell { color: "blue"; onClicked: helloText.color = color }
        Cell { color: "yellow"; onClicked: helloText.color = color }
        Cell { color: "steelblue"; onClicked: helloText.color = color }
        Cell { color: "black"; onClicked: helloText.color = color }
    }
}
//![0]