QtTaskTree::UntilIterator Class
class QtTaskTree::UntilIteratorFor要素内で使用する条件付きイテレータ。詳細...
| ヘッダー: | #include <qtasktree.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS TaskTree) target_link_libraries(mytarget PRIVATE Qt6::TaskTree) |
| qmake: | QT += tasktree |
| 以下のように: | Qt 6.11 |
| 継承元: | QtTaskTree::Iterator |
| ステータス: | テクノロジープレビュー |
このクラスはテクノロジープレビュー段階にあり、変更される可能性があります。
注:このクラスのすべての関数は再入可能です。
パブリック関数
| UntilIterator(const QtTaskTree::Iterator::Condition &condition) |
関連項目: Iterator 、ForeverIterator 、RepeatIterator 、およびListIteratorを参照してください 。
メンバー関数のドキュメント
[explicit] UntilIterator::UntilIterator(const QtTaskTree::Iterator::Condition &condition)
For (UntilIterator(condition)) >> Do {} 構文用の条件付きイテレータを生成します。このイテレータは、引数として渡されたcondition がtrueを返すまで繰り返し実行されます。
使用例:
static const intmaxNumber= 10;
const intluckyNumber=QRandomGenerator().global()->bounded(maxNumber);
qDebug() << "Today's lucky number is:" << luckyNumber;
qDebug() << "Let's start the drawing...";
const autoonConditionCheck= [luckyNumber](intiteration) {
if(iteration== 0)
return true;
const intdrawnNumber=QRandomGenerator().global()->bounded(maxNumber);
qDebug() << "You have drawn:" << drawnNumber;
boolwon=drawnNumber==luckyNumber;
if(won)
qDebug() << "You have won! Congratulations!";
return !won;
};
constGroup recipe=For (UntilIterator(onConditionCheck))>>Do {
timeoutTask(1s,DoneResult::Success)
};QTaskTree によってrecipe が開始された場合の、考えられる出力は以下の通りです:
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.