이 페이지에서

QtTaskTree::Iterator Class

class QtTaskTree::Iterator

For 요소 내에서 반복자로 사용할 베이스 클래스입니다. 더 보기...

헤더: #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

참고: 이 클래스의 모든 함수는 재인용됩니다.

공용 함수

qsizetype iteration() const

상세 설명

For, ForeverIterator, RepeatIterator, UntilIterator, 및 ListIterator참조하세요 .

멤버 함수 문서

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<< "seconds."; };const auto onDone = [iterator] {    qDebug() << "Finished" << iterator.iteration() << "iteration with timeout"
            << *iterator<< "seconds."; };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.

병렬 모드에서는 완료된 핸들러의 반복 인덱스 순서가 유지되지 않으며 완료된 작업의 순서에 따라 달라집니다. 병렬 Do 본문의 완료 처리기 내에서 반환된 반복 인덱스는 해당 설정 처리기의 원래 반복 인덱스와 일치하므로 후속 완료 처리기의 반복 인덱스 순서는 오름차순이 아닐 수 있습니다.

© 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.