QtTaskTree::Iterator Class
class QtTaskTree::IteratorFor 要素の内部でイテレータとして使用される基本クラスです。さらに...
| ヘッダー | #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 要素のハンドラボディの内部からのみ使用してください。Iterator がFor 要素に渡されることを確認してください。
使用例
constQList<std::chrono::seconds>timeouts={5s, 1s, 3s};constListIterator iterator(timeouts);const autoonSetup= [iterator](std::chrono::milliseconds&timeout) { timeout= *iterator; qDebug() << "Starting" << iterator.iteration() << "iteration with timeout" << *イテレータ<< "秒。"; };const autoonDone= [イテレータ]{. qDebug() << "Finished" << iterator.iteration() << "iteration with timeout" << *iterator<< "秒"; };constGroup sequentialRecipe=For(iterator)>>Do { (onSetup, onDone) };constGroup parallelRecipe = For(iterator)>>Do { parallel, onDone };constGroup parallelRecipe = For(iterator)>>Do { (onSetup, onDone) QTimeoutTask(onSetup,onDone) };constGroup 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 ハンドラ内の返された反復インデックスが、対応するセットアップ・ハンドラの元の反復のインデックスと一致するため、後続の 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.