QtTaskTree::Iterator Class
class QtTaskTree::Iterator'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::ForeverIterator, QtTaskTree::ListIterator, QtTaskTree::RepeatIterator 및 QtTaskTree::UntilIterator |
| 상태: | 기술 미리보기 |
이 클래스는 기술 미리보기 단계에 있으며 변경될 수 있습니다.
참고: 이 클래스의 모든 함수는 재진입 가능합니다.
공개 함수
For, ForeverIterator, RepeatIterator, UntilIterator 및 ListIterator도 참조하십시오 .
멤버 함수 설명
[constexpr noexcept default] Iterator::Iterator(QtTaskTree::Iterator &&other)
Iterator 의 인스턴스를 이동 생성합니다.
qsizetype Iterator::iteration() const
For (Iterator) >> 구문의 ` Do ` 본문 내에서 현재 실행 중인 핸들러의 반복 인덱스를 반환합니다. 이 함수는 레시피의 ` Do ` 본문에 배치된 ` GroupItem ` 요소의 핸들러 본문 내부에서만 사용해야 하며, 그렇지 않을 경우 프로그램이 중단될 수 있습니다. ` For ` 요소에 ` Iterator `가 전달되었는지 반드시 확인하십시오.
사용 예시:
const QList<std::chrono::seconds> timeouts = { 5s, 1s, 3s };
const ListIterator iterator(timeouts);
const auto onSetup = [iterator](std::chrono::milliseconds &timeout) {
timeout = *iterator;
qDebug() << "Starting" << iterator.iteration() << "iteration with timeout"
<< *iterator << "초.";
};
const auto onDone = [iterator] {
qDebug() << "Finished" << iterator.iteration() << "iteration with timeout"
<< *iterator << "초.";
};
const Group sequentialRecipe = For(iterator) >> Do {
QTimeoutTask(onSetup, onDone)
};
const Group parallelRecipe = For(iterator) >> Do {
parallel,
QTimeoutTask(onSetup, onDone)
};sequentialRecipe 를 실행하면 다음과 같은 결과가 출력됩니다:
Starting 0 iteration with timeout 5s seconds.
Finished 0 iteration with timeout 5s seconds.
Starting 1 iteration with timeout 1s seconds.
Finished 1 iteration with timeout 1s seconds.
Starting 2 iteration with timeout 3s seconds.
Finished 2 iteration with timeout 3s seconds.순차 모드에서는 done 핸들러 내의 반복 인덱스 순서가 보장됩니다.
parallelRecipe 를 실행했을 때의 출력 결과는 다음과 같습니다:
Starting 0 iteration with timeout 5s seconds.
Starting 1 iteration with timeout 1s seconds.
Starting 2 iteration with timeout 3s seconds.
Finished 1 iteration with timeout 1s seconds.
Finished 2 iteration with timeout 3s seconds.
Finished 0 iteration with timeout 5s seconds.병렬 모드에서는 done 핸들러 내의 반복 인덱스 순서가 유지된다고 보장되지 않으며, 완료된 작업의 순서에 따라 달라집니다. 병렬 Do 본문의 done 핸들러 내에서 반환되는 반복 인덱스는 해당 setup 핸들러에 대한 원래 반복의 인덱스와 일치하므로, 후속 done 핸들러에서 반복 인덱스의 순서가 오름차순이 아닐 수 있습니다.
© 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.