QtTaskTree::ForeverIterator Class
class QtTaskTree::ForeverIteratorFor 요소 내부에서 사용되는 무한 반복자. 더 보기...
| 헤더: | #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 |
| 상태: | 기술 미리보기 |
이 클래스는 기술 미리보기 단계에 있으며 변경될 수 있습니다.
참고: 이 클래스의 모든 함수는 재진입 가능합니다.
공개 함수
Iterator, RepeatIterator, UntilIterator 및 ListIterator도 참조하십시오 .
멤버 함수 설명
ForeverIterator::ForeverIterator()
For (ForeverIterator()) >> Do {} 구문을 위해 끝없이 반복되는 이터레이터를 생성합니다.
참고: Do 본문에서 병렬 모드를 지정하는 경우 각별히주의해야 합니다 . 이 경우 ` QTaskTree `가 무한한 수의 태스크를 인스턴스화할 수 있습니다.
사용 예시:
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 onNumberCheck = [luckyNumber] {
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 (ForeverIterator()) >> Do {
stopOnSuccess,
timeoutTask(1s),
QSyncTask(onNumberCheck)
};QTaskTree 에 의해 recipe 가 시작되었을 때 나올 수 있는 출력은 다음과 같습니다:
Today's lucky number is: 8
Let's start the drawing...
You have drawn: 2
You have drawn: 2
You have drawn: 6
You have drawn: 7
You have drawn: 9
You have drawn: 8
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.