summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/samegame/samegame1/Button.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/tutorials/samegame/samegame1/Button.qml')
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/Button.qml27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml
new file mode 100644
index 0000000..3846cf7
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml
@@ -0,0 +1,27 @@
+//![0]
+import Qt 4.6
+
+Rectangle {
+ id: Container
+
+ signal clicked
+ property string text: "Button"
+
+ color: activePalette.button; smooth: true
+ width: txtItem.width + 20; height: txtItem.height + 6
+ border.width: 1; border.color: activePalette.darker(activePalette.button); radius: 8;
+
+ gradient: Gradient {
+ GradientStop {
+ id: topGrad; position: 0.0
+ color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseRegion { id: mr; anchors.fill: parent; onClicked: Container.clicked() }
+
+ Text {
+ id: txtItem; text: Container.text; anchors.centerIn: Container; color: activePalette.buttonText
+ }
+}
+//![0]