// Copyright (C) 2017 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \title Qt Quick Examples - Threading \example threading \brief This is a collection of QML multithreading examples. \image qml-threading-example.png \ingroup qtquickexamples \e Threading is a collection of QML multithreading examples. \include examples-run.qdocinc \section1 Threaded ListModel \e{Threaded ListModel} contains a \l ListView and a \l ListModel. The ListModel object is updated asynchronously in another thread, and the results propagate back to the main thread. A timer requests updates from the worker thread periodically: \snippet threading/threadedlistmodel/timedisplay.qml 0 Inside the worker thread, the ListModel is synchronized once the data is finished loading: \snippet threading/threadedlistmodel/dataloader.mjs 0 \section1 WorkerScript \e WorkerScript contains an example of using a \l WorkerScript to offload expensive calculations into another thread. This keeps the UI from being blocked. This example calculates numbers in Pascal's Triangle, and not in a very optimal way, so it will often take several seconds to complete the calculation. By doing this in a WorkerScript in another thread, the UI is not blocked during this time. When the UI needs another value, a request is sent to the WorkerScript: \snippet threading/workerscript/workerscript.qml 0 The workerscript then is free to take a really long time to calculate it: \snippet threading/workerscript/workerscript.mjs 0 When it's done, the result returns to the main scene via the WorkerScript type: \snippet threading/workerscript/workerscript.qml 1 */