QtTaskTree::GroupItem Class
class QtTaskTree::GroupItemGroupItem represents the basic element that may be a part of any Group. 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 |
| Inherited By: | |
| Status: | Technical Preview |
Note: All functions in this class are reentrant.
Public Functions
| GroupItem(const QtTaskTree::Storage<StorageStruct> &storage) |
Detailed Description
GroupItem is a basic element that may be a part of any Group. It encapsulates the functionality provided by any GroupItem's subclass. It is a value type and it is safe to copy the GroupItem instance, even when it is originally created via the subclass' constructor.
There are four main kinds of GroupItem:
| GroupItem Kind | Brief Description |
|---|---|
| QCustomTask | Defines asynchronous task type and task's start, done, and error handlers. Aliased with a unique task name, such as, QThreadFunctionTask<ResultType> or QNetworkReplyWrapperTask. Asynchronous tasks are the main reason for using a task tree. |
| Group | A container for other group items. Since the group is of the GroupItem type, it's possible to nest it inside another group. The group is seen by its parent as a single asynchronous task. |
| GroupItem containing Storage | Enables the child tasks of a group to exchange data. When GroupItem containing Storage is placed inside a group, the task tree instantiates the storage's data object just before the group is entered, and destroys it just after the group is left. |
| Other group control items | The ExecutionMode or items returned by workflowPolicy() influence the group's behavior. The items returned by onGroupSetup() or onGroupDone() define custom handlers called when the group starts or ends execution. |
Member Function Documentation
template <typename StorageStruct> GroupItem::GroupItem(const QtTaskTree::Storage<StorageStruct> &storage)
Constructs a GroupItem element holding the storage object.
When the Group element containing this GroupItem is entered by the running task tree, an instance of the StorageStruct is created dynamically.
When that group is about to be left after its execution, the previously instantiated StorageStruct is deleted.
The dynamically created instance of StorageStruct is accessible from inside any handler body of the parent Group element, including nested groups and its tasks, via the Storage::operator->(), Storage::operator*(), or Storage::activeStorage() method.
See also Storage.