diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2009-10-26 05:57:41 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2009-10-26 05:57:41 (GMT) |
commit | 33071ea2211633df29fe14c5d196785d163253a6 (patch) | |
tree | 6c03fa4dcd8660d6fe1c62838b5109792bb00d49 /examples/declarative/connections | |
parent | 28cd6e0ed60df6f86a9d736b71ed00e26c224cdb (diff) | |
download | Qt-33071ea2211633df29fe14c5d196785d163253a6.zip Qt-33071ea2211633df29fe14c5d196785d163253a6.tar.gz Qt-33071ea2211633df29fe14c5d196785d163253a6.tar.bz2 |
improve connections example.
Diffstat (limited to 'examples/declarative/connections')
-rw-r--r-- | examples/declarative/connections/Button.qml | 12 | ||||
-rw-r--r-- | examples/declarative/connections/bg1.jpg | bin | 0 -> 23771 bytes | |||
-rw-r--r-- | examples/declarative/connections/connections.qml | 42 | ||||
-rw-r--r-- | examples/declarative/connections/rotate-left.png | bin | 0 -> 3061 bytes | |||
-rw-r--r-- | examples/declarative/connections/rotate-right.png | bin | 0 -> 3115 bytes |
5 files changed, 32 insertions, 22 deletions
diff --git a/examples/declarative/connections/Button.qml b/examples/declarative/connections/Button.qml new file mode 100644 index 0000000..1d46acc --- /dev/null +++ b/examples/declarative/connections/Button.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Item { + id: button + width: 48; height: 48 + + property alias image: icon.source + signal clicked + + Image { id: icon } + MouseRegion { anchors.fill: icon; onClicked: button.clicked() } +} diff --git a/examples/declarative/connections/bg1.jpg b/examples/declarative/connections/bg1.jpg Binary files differnew file mode 100644 index 0000000..dfc7cee --- /dev/null +++ b/examples/declarative/connections/bg1.jpg diff --git a/examples/declarative/connections/connections.qml b/examples/declarative/connections/connections.qml index b693b7e..5dc211e 100644 --- a/examples/declarative/connections/connections.qml +++ b/examples/declarative/connections/connections.qml @@ -1,32 +1,30 @@ import Qt 4.6 Rectangle { - id: rect - color: "blue" - width: 40 - height: 30 + id: window; color: "#343434" + width: 640; height: 480 - Rectangle { - id: dot - color: "red" - width: 3 - height: 3 - x: rect.width/2 - y: rect.height/2 + function turnLeft() { + image.rotation -= 90 + } + function turnRight() { + image.rotation += 90 } - MouseRegion { - id: mr - anchors.fill: rect + Image { + id: image; source: "bg1.jpg"; anchors.centerIn: parent; transformOrigin: Item.Center + rotation: Behavior { NumberAnimation { easing: "easeOutCubic"; duration: 300 } } } - Connection { - sender: mr - signal: "clicked(mouse)" - script: { - color = "green"; - dot.x = mouse.x-1; - dot.y = mouse.y-1; - } + Button { + id: leftButton; image: "rotate-left.png" + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 10 } + } + Button { + id: rightButton; image: "rotate-right.png" + anchors { right: parent.right; bottom: parent.bottom; rightMargin: 10; bottomMargin: 10 } } + + Connection { sender: leftButton; signal: "clicked()"; script: window.turnLeft() } + Connection { sender: rightButton; signal: "clicked()"; script: window.turnRight() } } diff --git a/examples/declarative/connections/rotate-left.png b/examples/declarative/connections/rotate-left.png Binary files differnew file mode 100644 index 0000000..c30387e --- /dev/null +++ b/examples/declarative/connections/rotate-left.png diff --git a/examples/declarative/connections/rotate-right.png b/examples/declarative/connections/rotate-right.png Binary files differnew file mode 100644 index 0000000..1b05674 --- /dev/null +++ b/examples/declarative/connections/rotate-right.png |