aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels/doc/snippets/qml/listmodel/WorkerScript.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmlmodels/doc/snippets/qml/listmodel/WorkerScript.qml')
-rw-r--r--src/qmlmodels/doc/snippets/qml/listmodel/WorkerScript.qml43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/qmlmodels/doc/snippets/qml/listmodel/WorkerScript.qml b/src/qmlmodels/doc/snippets/qml/listmodel/WorkerScript.qml
new file mode 100644
index 0000000000..4799878375
--- /dev/null
+++ b/src/qmlmodels/doc/snippets/qml/listmodel/WorkerScript.qml
@@ -0,0 +1,43 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Rectangle {
+ color: "white"
+ width: 200
+ height: 300
+
+ ListView {
+ anchors.fill: parent
+ model: listModel
+ delegate: Component {
+ Text {
+ required property string time
+ text: time
+ }
+ }
+
+ ListModel { id: listModel }
+
+ WorkerScript {
+ id: worker
+ source: "dataloader.mjs"
+ }
+
+// ![0]
+ Timer {
+ id: timer
+ interval: 2000; repeat: true
+ running: true
+ triggeredOnStart: true
+
+ onTriggered: {
+ var msg = {'action': 'appendCurrentTime', 'model': listModel};
+ worker.sendMessage(msg);
+ }
+ }
+// ![0]
+ }
+}
+