1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5 \page concurrent-changes-qt6.html
6 \title Changes to Qt Concurrent
7 \ingroup changes-qt-5-to-6
8 \brief Improved to work with a variable number of arguments.
10 Qt 6 is a result of the conscious effort to make the framework more
11 efficient and easy to use.
13 We try to maintain binary and source compatibility for all the public
14 APIs in each release. But some changes were inevitable in an effort to
15 make Qt a better framework.
17 In this topic we summarize those changes in Qt Concurrent, and provide
18 guidance to handle them.
20 \section1 QtConcurrent::run()
22 QtConcurrent::run() has been improved to work with a variable number
23 of arguments, so the signatures are changed to:
28 QFuture<T> run(Function &&f, Args &&...args)
30 // run with a QThreadPool argument
32 QFuture<T> run(QThreadPool *pool, Function &&f, Args &&...args)
35 As a side effect, if \c f is a pointer to a member function, the first
36 argument of \c args should be the object for which that member is defined
37 (or a reference, or a pointer to it). So instead of writing:
41 QFuture<void> future = QtConcurrent::run(&image, &QImage::invertPixels, QImage::InvertRgba);
47 QFuture<void> future = QtConcurrent::run(&QImage::invertPixels, &image, QImage::InvertRgba);
50 Another side effect is that \c QtConcurrent::run() will not work with
51 overloaded functions anymore. For example, the code below won't compile:
53 \include qtconcurrentrun.cpp run-with-overload-calls
55 Other methods of QtConcurrent have no behavioral changes and do not introduce
56 source compatibility breaks.