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

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

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

    states: State {
        name: "reanchored"

        AnchorChanges {
            target: myRect
            anchors.top: window.top
            anchors.bottom: window.bottom
        }
        PropertyChanges {
            target: myRect
            anchors.topMargin: 3
            anchors.bottomMargin: 3
        }
    }

    MouseArea { anchors.fill: parent; onClicked: window.state = "reanchored" }
}
//![0]