summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/codingconventions/photo.qml
blob: c28c2c985a7f20a2c96641ac0278dcfddb403e45 (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
import Qt 4.7

//! [0]
Rectangle {
    id: photo                                               // id on the first line makes it easy to find an object

    property bool thumbnail: false                          // property declarations
    property alias image: photoImage.source

    signal clicked                                          // signal declarations

    function doSomething(x) {                               // javascript functions
        return x + photoImage.width
    }

    x: 20; y: 20; width: 200; height: 150                   // object properties
    color: "gray"                                           // try to group related properties together

    Rectangle {                                             // child objects
        id: border
        anchors.centerIn: parent; color: "white"

        Image { id: photoImage; anchors.centerIn: parent }
    }

    states: State {                                         // states
        name: "selected"
        PropertyChanges { target: border; color: "red" }
    }

    transitions: Transition {                               // transitions
        from: ""; to: "selected"
        ColorAnimation { target: border; duration: 200 }
    }
}
//! [0]