diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-30 06:25:37 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-30 06:25:37 (GMT) |
commit | 1c8cf1b080c81c40bedc9d7c342555585fc394b0 (patch) | |
tree | 3aa4b9eec3c31773ee878ec8c4e23439428f3f08 /examples/declarative/workerscript | |
parent | 34e5b058c81757e58f7356290d7866f37a52be53 (diff) | |
download | Qt-1c8cf1b080c81c40bedc9d7c342555585fc394b0.zip Qt-1c8cf1b080c81c40bedc9d7c342555585fc394b0.tar.gz Qt-1c8cf1b080c81c40bedc9d7c342555585fc394b0.tar.bz2 |
Basic WorkerScript functionality
Diffstat (limited to 'examples/declarative/workerscript')
-rw-r--r-- | examples/declarative/workerscript/workerscript.js | 5 | ||||
-rw-r--r-- | examples/declarative/workerscript/workerscript.qml | 41 |
2 files changed, 46 insertions, 0 deletions
diff --git a/examples/declarative/workerscript/workerscript.js b/examples/declarative/workerscript/workerscript.js new file mode 100644 index 0000000..060c04a --- /dev/null +++ b/examples/declarative/workerscript/workerscript.js @@ -0,0 +1,5 @@ +onmessage = function(message) { + print ("You clicked the " + message.rectangle + " rectangle."); + print ("The coordinates were: " + message.x + "," + message.y); +} + diff --git a/examples/declarative/workerscript/workerscript.qml b/examples/declarative/workerscript/workerscript.qml new file mode 100644 index 0000000..3729022 --- /dev/null +++ b/examples/declarative/workerscript/workerscript.qml @@ -0,0 +1,41 @@ +import Qt 4.6 + +Rectangle { + width: 480; height: 320; + + WorkerScript { + id: myWorker + source: "workerscript.js" + } + + Rectangle { + width: 200; height: 200 + anchors.left: parent.left + anchors.leftMargin: 20 + color: "red" + + MouseRegion { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); + } + } + + Rectangle { + width: 200; height: 200 + anchors.right: parent.right + anchors.rightMargin: 20 + color: "blue" + + MouseRegion { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); + } + } + + Text { + text: "Click a Rectangle!" + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: 50 + } +} |