QTaskBuilder Class

template <typename Task, typename... Args> class QtConcurrent::QTaskBuilder

The QTaskBuilder class is used for adjusting task parameters. More...

Header: #include <QTaskBuilder>
CMake: find_package(Qt6 REQUIRED COMPONENTS Concurrent)
target_link_libraries(mytarget PRIVATE Qt6::Concurrent)
qmake: QT += concurrent
Since: Qt 6.0

Public Functions

QtConcurrent::QTaskBuilder<Task, Args...> &onThreadPool(QThreadPool &newThreadPool)
QFuture<QtConcurrent::InvokeResultType> spawn()
void spawn(QtConcurrent::FutureResult)
QtConcurrent::QTaskBuilder<Task, ExtraArgs...> withArguments(ExtraArgs &&... args)
QtConcurrent::QTaskBuilder<Task, Args...> &withPriority(int newPriority)

Detailed Description

It's not possible to create an object of this class manually. See Concurrent Task for more details and usage examples.

Member Function Documentation

QtConcurrent::QTaskBuilder<Task, Args...> &QTaskBuilder::onThreadPool(QThreadPool &newThreadPool)

Sets the thread pool newThreadPool that the task will be invoked on.

QFuture<QtConcurrent::InvokeResultType> QTaskBuilder::spawn()

Runs the task in a separate thread and returns a future object immediately. This is a non-blocking call. The task might not start immediately.

void QTaskBuilder::spawn(QtConcurrent::FutureResult)

Runs the task in a separate thread. This is a non-blocking call. The task might not start immediately.

template <typename... ExtraArgs> QtConcurrent::QTaskBuilder<Task, ExtraArgs...> QTaskBuilder::withArguments(ExtraArgs &&... args)

Sets the arguments args the task will be invoked with. The code is ill-formed (causes compilation errors) if:

  • This function is invoked more than once.
  • The arguments count is zero.

QtConcurrent::QTaskBuilder<Task, Args...> &QTaskBuilder::withPriority(int newPriority)

Sets the priority newPriority that the task will be invoked with.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.