このページでは

QtTaskTree::QSyncTask Class

class QtTaskTree::QSyncTask

カスタムハンドラを他のタスクと同期して実行する。さらに...

ヘッダ #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

注意:このクラスの関数はすべてリエントラントです。

パブリック関数

QSyncTask(Handler &&handler)

詳細説明

QSyncTask は、他のタスクの間に追加のハンドラを実行したい場合に便利です。QSyncTask は、親タスクGroup からは他のタスクと同じように見えます。QSyncTaskのハンドラ本体は呼び出し元のスレッドから同期的に実行されるため、長時間実行することは避けてください。やむを得ない場合は、代わりにQThreadFunctionTask

メンバ関数ドキュメント

[explicit] template <typename Handler, std::enable_if_t<!std::is_same_v<q20::remove_cvref_t<Handler>, QSyncTask>, bool> = true> QSyncTask::QSyncTask(Handler &&handler)

渡されたhandler を同期的に実行する要素を構築する。Handlerstd::function<DoneResult()> 型である。handler が返すDoneResult の値は、親グループのworkflow policy 解決時に考慮される。オプションで、std::function<void()> の短縮形も受け付ける。この場合、戻り値はDoneResult::Success であると仮定される。

渡されたhandler は、呼び出し元のスレッドから同期的に実行されるので、ハンドラ本体の長時 間実行は避けること。そうでない場合は、QThreadFunctionTask の使用を検討してください。

注意: QSyncTask 要素は、タスク・ツリーの進行状況を報告する際にはタスクとしてカウントされず、QTaskTree::taskCount() やQTaskTree::progressMaximum() には含まれません。

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