QtTaskTree::UntilIterator Class | Qt TaskTree | Qt 6.11.1
Description: The conditional iterator to be used inside For element.

- Qt 6.11
- Qt TaskTree
- C++ Classes
- UntilIterator
- Qt 6.11.1 Reference Documentation

# QtTaskTree::UntilIterator Class

class QtTaskTree::UntilIterator

The conditional iterator to be used inside For element. 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: | QtTaskTree::Iterator

- List of all members, including inherited members

Note: All functions in this class are reentrant.

## Public Functions

| UntilIterator(const QtTaskTree::Iterator::Condition &condition)

## Detailed Description

See also Iterator, ForeverIterator, RepeatIterator, and ListIterator.

## Member Function Documentation

### `[explicit]` UntilIterator::UntilIterator(const QtTaskTree::Iterator::Condition &condition)

Constructs the conditional iterator for the For (UntilIterator(condition)) >> Do {} construct. The iterator will repeat until passed condition returns true.

Example usage:

     static const int maxNumber = 10;
     const int luckyNumber = QRandomGenerator().global()->bounded(maxNumber);

     qDebug() << "Today's lucky number is:" << luckyNumber;
     qDebug() << "Let's start the drawing...";

     const auto onConditionCheck = [luckyNumber](int iteration) {
         if (iteration == 0)
             return true;
         const int drawnNumber = QRandomGenerator().global()->bounded(maxNumber);
         qDebug() << "You have drawn:" << drawnNumber;
         bool won = drawnNumber == luckyNumber;
         if (won)
             qDebug() << "You have won! Congratulations!";
         return !won;
     };

     const Group recipe = For (UntilIterator(onConditionCheck)) >> Do {
         timeoutTask(1s, DoneResult::Success)
     };

The possible output when the `recipe` is started by the QTaskTree:

     Today's lucky number is: 7
     Let's start the drawing...
     You have drawn: 2
     You have drawn: 5
     You have drawn: 0
     You have drawn: 2
     You have drawn: 4
     You have drawn: 9
     You have drawn: 9
     You have drawn: 7
     You have won! Congratulations!