summaryrefslogtreecommitdiffstats
path: root/examples/declarative/flipable/flipable-example.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/flipable/flipable-example.qml')
-rw-r--r--examples/declarative/flipable/flipable-example.qml37
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/declarative/flipable/flipable-example.qml b/examples/declarative/flipable/flipable-example.qml
new file mode 100644
index 0000000..c837ebc
--- /dev/null
+++ b/examples/declarative/flipable/flipable-example.qml
@@ -0,0 +1,37 @@
+//! [0]
+import Qt 4.6
+
+Flipable {
+ id: flipable
+ width: 240
+ height: 240
+
+ property int angle: 0
+ property bool flipped: false
+
+ front: Image { source: "front.png" }
+ back: Image { source: "back.png" }
+
+ transform: Rotation {
+ origin.x: flipable.width/2; origin.y: flipable.height/2
+ axis.x: 0; axis.y: 1; axis.z: 0 // rotate around y-axis
+ angle: flipable.angle
+ }
+
+ states: State {
+ name: "back"
+ PropertyChanges { target: flipable; angle: 180 }
+ when: flipable.flipped
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "angle"; duration: 1000 }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: flipable.flipped = !flipable.flipped
+ }
+}
+//! [0]
+