diff options
| author | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2023-06-23 16:11:31 +0200 |
|---|---|---|
| committer | Oliver Eftevaag <oliver.eftevaag@qt.io> | 2023-07-04 00:18:47 +0200 |
| commit | 38373b81f37ccbf6ec66f43a70fe9622bbcc9593 (patch) | |
| tree | b66eeb48b0a982cb3fd19e18ca8468dec6c1700f /tests/manual/threading/workerscript/workerscript.qml | |
| parent | add2620e2e710bd2f594973f22f048314d7060d8 (diff) | |
convert threading example to manual tests
The threading example used a LauncherList to combine
two different but related examples into one.
I've now separated both into a shared directory called
'threading'
Pick-to: 6.6
Change-Id: Iee8898e61adcf69dc67157a1eff5f6ac019a39ca
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/manual/threading/workerscript/workerscript.qml')
| -rw-r--r-- | tests/manual/threading/workerscript/workerscript.qml | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/manual/threading/workerscript/workerscript.qml b/tests/manual/threading/workerscript/workerscript.qml new file mode 100644 index 0000000000..f6c49e6140 --- /dev/null +++ b/tests/manual/threading/workerscript/workerscript.qml @@ -0,0 +1,60 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick + +Rectangle { + width: 320; height: 480 + + WorkerScript { + id: myWorker + source: "workerscript.mjs" + + onMessage: (messageObject) => { + if (messageObject.row == rowSpinner.value && messageObject.column == columnSpinner.value){ //Not an old result + if (messageObject.result == -1) + resultText.text = "Column must be <= Row"; + else + resultText.text = messageObject.result; + } + } + } + + Row { + y: 24 + spacing: 24 + anchors.horizontalCenter: parent.horizontalCenter + + Spinner { + id: rowSpinner + label: "Row" + onValueChanged: { + resultText.text = "Loading..."; + myWorker.sendMessage( { row: rowSpinner.value, column: columnSpinner.value } ); + } + } + + Spinner { + id: columnSpinner + label: "Column" + onValueChanged: { + resultText.text = "Loading..."; + myWorker.sendMessage( { row: rowSpinner.value, column: columnSpinner.value } ); + } + } + } + + Text { + id: resultText + y: 180 + width: parent.width + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + font.pixelSize: 32 + } + + Text { + text: "Pascal's Triangle Calculator" + anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } + } +} |
