- Extending Qt Creator Manual
- QtTaskTree
- ExecutableItem
- Extending Qt Creator Manual 21.0.0-beta1

# QtTaskTree::ExecutableItem Class

class QtTaskTree::ExecutableItem

Base class for executable task items. More...

Header: | `#include <qtasktree.h>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS TaskTree)` `target_link_libraries(mytarget PRIVATE Qt6::TaskTree)`
qmake: | `QT += tasktree`
Since: | 6.11
Inherits: | QtTaskTree::GroupItem
Inherited By: | QtTaskTree::Forever, QtTaskTree::Group, QtTaskTree::QCustomTask, and QtTaskTree::QSyncTask

- List of all members, including inherited members

Note: All functions in this class are reentrant.

## Public Functions

class QtTaskTree::Group | withAccept(ObjectSignalGetter &&getter) const
class QtTaskTree::Group | withCancel(ObjectSignalGetter &&getter, int postCancelRecipe = {}) const

## Detailed Description

ExecutableItem provides an additional interface for items containing executable tasks. Use withTimeout() to attach a timeout to a task. Use withLog() to include debugging information about the task startup and the execution result.

## Member Function Documentation

### template <typename ObjectSignalGetter> class QtTaskTree::Group ExecutableItem::withAccept(ObjectSignalGetter &&getter) const

Returns a copy of `this` ExecutableItem coupled with a signal awaiter. The passed getter is a function returning a ObjectSignal that describes the emitter and its awaiting signal. Use makeObjectSignal() inside the getter to create an ObjectSignal object.

When `this` ExecutableItem finishes with an error, the returned Group finishes immediately with an error, without awaiting for the awaiter's signal.

When `this` ExecutableItem finishes with success, the returned Group doesn't finish immediately but waits for the awaiting signal to be sent. After the awaiting signal is sent, the returned Group finishes with success. If the awaiting signal is sent before `this` ExecutableItem finishes, the awaiting phase is skipped and the returned Group finishes synchronously.

The connection to the awaiter's signal is established when `this` ExecutableItem is about to be started. If the awaiting signal was triggered before, this won't be noticed after `this` ExecutableItem is started.

### template <typename ObjectSignalGetter> class QtTaskTree::Group ExecutableItem::withCancel(ObjectSignalGetter &&getter, int postCancelRecipe = {}) const

Makes a copy of `this` ExecutableItem cancelable. The passed getter is a function returning a ObjectSignal that describes the emitter and its cancellation signal. Use makeObjectSignal() inside the getter to create an ObjectSignal object. When the cancellation signal is emitted, `this` ExecutableItem is canceled, an optionally provided postCancelRecipe is executed, and returned Group finishes with an error.

When `this` ExecutableItem finishes before the cancellation signal is emitted, the returned Group finishes immediately with the same result that `this` ExecutableItem finished. In this case the optionally provided postCancelRecipe is skipped.

The connection to the cancellation signal is established when `this` ExecutableItem is about to be started. If the cancelation signal was triggered before, this won't be noticed after `this` ExecutableItem is started.