QtTaskTree::UntilIterator Class
class QtTaskTree::UntilIterator将在 For element 中使用的条件迭代器。更多内容...
| 标题: | #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;
bool赢=抽取的数字==幸运数字;
if(赢)
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.