summaryrefslogtreecommitdiffstats
path: root/examples/declarative/layouts/positioners/Button.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/layouts/positioners/Button.qml')
-rw-r--r--examples/declarative/layouts/positioners/Button.qml38
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/declarative/layouts/positioners/Button.qml b/examples/declarative/layouts/positioners/Button.qml
new file mode 100644
index 0000000..d03eeb5
--- /dev/null
+++ b/examples/declarative/layouts/positioners/Button.qml
@@ -0,0 +1,38 @@
+import Qt 4.7
+
+Rectangle {
+ id: page
+
+ property string text
+ property string icon
+ signal clicked
+
+ border.color: "black"; color: "steelblue"; radius: 5
+ width: pix.width + textelement.width + 13
+ height: pix.height + 10
+
+ Image { id: pix; x: 5; y:5; source: parent.icon }
+
+ Text {
+ id: textelement
+ text: page.text; color: "white"
+ x: pix.width + pix.x + 3
+ anchors.verticalCenter: pix.verticalCenter
+ }
+
+ MouseArea {
+ id: mr
+ anchors.fill: parent
+ onClicked: { parent.focus = true; page.clicked() }
+ }
+
+ states: State {
+ name: "pressed"; when: mr.pressed
+ PropertyChanges { target: textelement; x: 5 }
+ PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 }
+ }
+}