Sur cette page

QtTaskTree::UntilIterator Class

class QtTaskTree::UntilIterator

L'itérateur conditionnel à utiliser à l'intérieur de l'élément « For ». En savoir plus...

En-tête : #include <qtasktree.h>
CMake : find_package(Qt6 REQUIRED COMPONENTS TaskTree)
target_link_libraries(mytarget PRIVATE Qt6::TaskTree)
qmake : QT += tasktree
Depuis : Qt 6.11
Hérite de : QtTaskTree::Iterator
Statut : Aperçu technologique

Cette classe est en avant-première technologique et est susceptible d'être modifiée.

Remarque : toutes les fonctions de cette classe sont réentrantes.

Fonctions publiques

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

Description détaillée

Voir également Iterator, ForeverIterator, RepeatIterator et ListIterator.

Documentation sur les fonctions membres

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

Crée l'itérateur conditionnel pour la construction « For (UntilIterator(condition)) >> Do {} ». L'itérateur s'exécutera en boucle jusqu'à ce que l'condition e transmise renvoie « true ».

Exemple d'utilisation :

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 aGagné = nombreTiré== nombreChanceux;
    if (aGagné)
        qDebug() << "You have won! Congratulations!";
   return !won;
};

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

Résultat possible lorsque l’ recipe est lancé par l’ 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!

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.