QtTaskTree::If Class
class QtTaskTree::IfAn "if" element used in conditional expressions. More...
| Header: | #include <qconditional.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS TaskTree)target_link_libraries(mytarget PRIVATE Qt6::TaskTree) |
| qmake: | QT += tasktree |
| Since: | 6.11 |
Note: All functions in this class are reentrant.
Public Functions
| If(Handler &&handler) |
Detailed Description
An initial condition element of the conditional expressions. Must always be followed by Then element.
The conditional expressions in the TaskTree module enable processing of branch conditions and their bodies in an asynchronous way. For example:
const Group recipe { If (conditionTask1) >> Then { bodyTask1 } >> ElseIf (conditionTask2) >> Then { bodyTask2 } >> Else { bodyTask3 } };
When the above recipe is run with QTaskTree, the task tree starts the asynchronous conditionTask1 first. After it's finished, depending on the result, the task tree may either execute the bodyTask1 when the conditionTask1 finished with success, or dispatch another condition by executing conditionTask2 otherwise. In case the bodyTask1 is executed, no other tasks are executed, and the result of bodyTask1 is the final result of the whole conditional expression.
See also Then, Else, and ElseIf.
Member Function Documentation
[explicit] template <typename Handler, int = true> If::If(Handler &&handler)
A helper constructor accepting the synchronous handler to be executed when evaluating the initial condition by the running QTaskTree.
It's a shortcut for:
If (QSyncTask(handler))
See QSyncTask for more information on what handler types are acceptable.