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
7
class
MyClass
:
public
QObject
8
{
9
Q_OBJECT
10
public
:
11
signals
:
12
void
handleFinished
();
13
};
14
15
void
examples
()
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
}
MyClass
[5]
Definition
doc_src_properties.cpp:66
examples
bool examples()
[3]
Definition
src_corelib_global_qglobal.cpp:43
qtbase
src
corelib
doc
snippets
code
src_corelib_thread_qfuturewatcher.cpp
Generated on
for Qt by
1.14.0