diff options
Diffstat (limited to 'doc/src/snippets/declarative/state.qml')
-rw-r--r-- | doc/src/snippets/declarative/state.qml | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/src/snippets/declarative/state.qml b/doc/src/snippets/declarative/state.qml new file mode 100644 index 0000000..0954298 --- /dev/null +++ b/doc/src/snippets/declarative/state.qml @@ -0,0 +1,29 @@ +//![0] +import Qt 4.7 + +Rectangle { + id: myRect + width: 100; height: 100 + color: "black" + + states: [ + State { + name: "clicked" + PropertyChanges { + target: myRect + color: "red" + } + } + ] + + MouseArea { + anchors.fill: parent + onClicked: { + if (myRect.state == "") // i.e. the default state + myRect.state = "clicked"; + else + myRect.state = ""; + } + } +} +//![0] |