aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml')
-rw-r--r--src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml b/src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml
new file mode 100644
index 0000000000..509c1f5bf0
--- /dev/null
+++ b/src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml
@@ -0,0 +1,27 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+//![0]
+import QtQuick
+
+Rectangle {
+ width: 300; height: 300
+
+ Text {
+ id: myText
+ text: 'Click anywhere'
+ }
+
+ WorkerScript {
+ id: myWorker
+ source: "script.mjs"
+
+ onMessage: (messageObject)=> myText.text = messageObject.reply
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: (mouse)=> myWorker.sendMessage({ 'x': mouse.x, 'y': mouse.y })
+ }
+}
+//![0]