QtTaskTree::Group Class
class QtTaskTree::Groupグループは、非同期タスクのネストされたツリーを実行し、処理する方法を記述する宣言的なレシピを構成するための基本的な要素を表します。詳細...
| ヘッダー | #include <qtasktree.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS TaskTree)target_link_libraries(mytarget PRIVATE Qt6::TaskTree) |
| qmake: | QT += tasktree |
| 以来: | Qt 6.11 |
| 継承: | QtTaskTree::ExecutableItem |
注意:このクラスの関数はすべてリエントラントです。
パブリック関数
| Group(const QtTaskTree::GroupItems &children) | |
| Group(std::initializer_list<QtTaskTree::GroupItem> children) |
詳細説明
グループは他のグループアイテムのコンテナです。子タスクを1つの単位に囲み、グループの親からは1つの非同期タスクとみなされます。Group はGroupItem 型であるため、Group の子であることもあります。
グループに子タスクを挿入するには、QThreadFunctionTask<ResultType> やQNetworkReplyWrapperTask のように、エイリアスを使ったカスタム・タスク名を使います:
const Group group { QNetworkReplyWrapperTask(...), QThreadFunctionTask<int>(...) };
ExecutionMode またはWorkflowPolicy アイテムを挿入して、グループの動作をカスタマイズできる:
const Group group { parallel, continueOnError, QNetworkReplyWrapperTask(...), QNetworkReplyWrapperTask(...) };
グループはネストしたグループを含むことができる:
const Group group { finishAllAndSuccess, QNetworkReplyWrapperTask(...), Group { QNetworkReplyWrapperTask(...), Group { parallel, QNetworkReplyWrapperTask(...), QNetworkReplyWrapperTask(...), } QThreadFunctionTask<QString>(...) } };
グループは、カスタムストレージ構造を動的にインスタンス化することができ、 タスク間のデータ交換に使用することができる:
struct MyCustomStruct { QByteArray data; }; Storage<MyCustomStruct> storage; const auto onFirstSetup = [](QNetworkReplyWrapper &task) { ... }; const auto onFirstDone = [storage](const QNetworkReplyWrapper &task) { // storage-> gives a pointer to MyCustomStruct instance, // created dynamically by the running task tree. storage->data = task.reply()->readAll(); }; const auto onSecondSetup = [storage](QThreadFunction<QImage> &task) { // storage-> gives a pointer to MyCustomStruct. Since the group is sequential, // the stored MyCustomStruct was already updated inside the onFirstDone handler. const QByteArray storedData = storage->data; }; const Group group { // When the group is entered by a running task tree, it creates MyCustomStruct // instance dynamically. It is later accessible from all handlers via // the *storage or storage-> operators. sequential, storage, QNetworkReplyWrapperTask(onFirstSetup, onFirstDone, CallDoneFlag::OnSuccess), QThreadFunctionTask<QImage>(onSecondSetup) };
メンバー関数ドキュメント
Group::Group(const QtTaskTree::GroupItems &children)
与えられたリストchildren でグループを構築する。
このコンストラクタは、グループの子項目がコンパイル時にはわからないが、後で実行時にわかる場合に便利である:
const QStringList sourceList = ...; GroupItems groupItems { parallel }; for (const QString &source : sourceList) { const QNetworkReplyWrapperTask task(...); // use source for setup handler groupItems << task; } const Group group(groupItems);
Group::Group(std::initializer_list<QtTaskTree::GroupItem> children)
children で与えられたstd::initializer_list からグループを構築する。
このコンストラクタは、コンパイル時にグループのすべての子項目がわかっている場合に便利です:
const Group group { finishAllAndSuccess, QNetworkReplyWrapperTask(...), Group { QNetworkReplyWrapperTask(...), Group { parallel, QNetworkReplyWrapperTask(...), QNetworkReplyWrapperTask(...), } QThreadFunctionTask<QString>(...) } };
© 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.