QtTaskTree::QTaskInterface Class | Qt TaskTree | Qt 6.11.2
Description: QTaskInterface is a helper class used when adapting custom task's interface.

- Qt 6.11
- Qt TaskTree
- C++ Classes
- QTaskInterface
- Qt 6.11.2 Reference Documentation

# QtTaskTree::QTaskInterface Class

class QtTaskTree::QTaskInterface

QTaskInterface is a helper class used when adapting custom task's interface. More...

Header: | `#include <qtasktree.h>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS TaskTree)` `target_link_libraries(mytarget PRIVATE Qt6::TaskTree)`
qmake: | `QT += tasktree`
Since: | Qt 6.11
Inherits: | QObject

- List of all members, including inherited members

Note: All functions in this class are reentrant.

## Public Functions

void | reportDone(QtTaskTree::DoneResult result)

## Signals

void | done(QtTaskTree::DoneResult result)

## Reimplemented Protected Functions

virtual bool | event(QEvent *event) override

## Detailed Description

The custom `Adapter` type of the QCustomTask<`Task`, `Adapter`, `Deleter>` template is expected to have the following form, when adapting Worker task:

     class WorkerTaskAdapter
     {
     public:
         void operator()(Worker *task, QTaskInterface *iface) { ... }
     };

     using WorkerTask = QCustomTask<Worker, WorkerTaskAdapter>;

## Member Function Documentation

### `[private signal]` void QTaskInterface::done(QtTaskTree::DoneResult result)

This signal is emitted when reportDone() is called, passing the result of the task execution.

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.

See also reportDone().

### `[override virtual protected]` bool QTaskInterface::event(QEvent *event)

Reimplements: QObject::event(QEvent *e).

### void QTaskInterface::reportDone(QtTaskTree::DoneResult result)

This method should be called when the task adapted via custom adapter is finished, passing the result of the task execution.

Assuming the Worker emits a finished(bool) signal, the adapter may look like:

     class WorkerTaskAdapter
     {
     public:
         void operator()(Worker *task, QTaskInterface *iface) {
             connect(task, &Worker::finished, iface, [iface](bool success) {
                 iface->reportDone(toDoneResult(success));
             });
             task->execute();
         }
     };

     using WorkerTask = QCustomTask<Worker, WorkerTaskAdapter>;

See also QCustomTask.