summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-11-24 06:14:05 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-11-24 06:14:05 (GMT)
commitb5b22e8f34c7fa51cc979e2554accc80847c7de9 (patch)
tree9224d0c2cd48137860c0d34d4bd0f752d0729c1a
parent635dc8d2746a1409e7cdd91cfa451519248715bb (diff)
downloadQt-b5b22e8f34c7fa51cc979e2554accc80847c7de9.zip
Qt-b5b22e8f34c7fa51cc979e2554accc80847c7de9.tar.gz
Qt-b5b22e8f34c7fa51cc979e2554accc80847c7de9.tar.bz2
Fix doc example code
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflipable.cpp46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp
index 57d2ee1..9e48bf2 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp
@@ -68,29 +68,39 @@ public:
Flipable allows you to specify a front and a back and then flip between those sides.
+ Here's an example that flips between the front and back sides when clicked:
+
\qml
-Flipable {
- width: 40; height: 40
-
- transform: Rotation {
- id: rotation
- origin.x: 20; origin.y: 120
- axis.x: 0; axis.y: 1; axis.z: 0
- angle: 0
- }
- front: Image { source: "front.png" }
- back: Image { source: "back.png" }
+ Flipable {
+ id: flipable
+ width: 250; height: 250
+ property int angle: 0
- states: State {
- name: "back"
- SetProperties { target: rotation; angle: 180 }
- }
+ transform: Rotation {
+ id: 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
+ }
+
+ front: Image { source: "front.png" }
+ back: Image { source: "back.png" }
- transitions: Transition {
- NumberAnimation { easing: "easeInOutQuad"; matchProperties: "rotation" }
+ states: State {
+ name: "back"
+ PropertyChanges { target: flipable; angle: 180 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { matchProperties: "angle"; duration: 2000 }
+ }
+
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: flipable.state = (flipable.state == 'back' ? 'front' : 'back')
+ }
}
-}
\endqml
\image flipable.gif