Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_corelib_thread_qfuturewatcher.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QFutureWatcher>
5#include <QtConcurrent>
6
7class MyClass : public QObject
8{
10public:
13};
14
16{
17 int result;
18
19 //! [0]
20 // Instantiate the objects and connect to the finished signal.
21 MyClass myObject;
22 QFutureWatcher<int> watcher;
23 QObject::connect(&watcher, &QFutureWatcher<int>::finished, &myObject, &MyClass::handleFinished);
24
25 // Start the computation.
26 QFuture<int> future = QtConcurrent::run([result](){ /*...*/ return result;});
27 watcher.setFuture(future);
28 //! [0]
29}
bool examples()
[3]