このページでは

QtTaskTree::QTaskInterface Class

class QtTaskTree::QTaskInterface

QTaskInterface はカスタムタスクのインターフェイスを適合させるときに使われるヘルパークラスです。詳細...

ヘッダー #include <qtasktree.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS TaskTree)
target_link_libraries(mytarget PRIVATE Qt6::TaskTree)
qmake: QT += tasktree
以来:Qt 6.11
継承: QObject

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

パブリック関数

void reportDone(QtTaskTree::DoneResult result)

再実装された保護された関数

virtual bool event(QEvent *event) override

詳細説明

QCustomTask<Task,Adapter,Deleter> テンプレートのカスタムAdapter タイプは、Worker タスクを適応させる場合、以下のフォームを持つことが期待される:

class WorkerTaskAdapter
{
public:
    void operator()(Worker *task, QTaskInterface *iface) { ... }
};

using WorkerTask = QCustomTask<Worker, WorkerTaskAdapter>;

メンバ関数ドキュメント

[override virtual protected] bool QTaskInterface::event(QEvent *event)

再インプリメント:QObject::event(QEvent *e).

void QTaskInterface::reportDone(QtTaskTree::DoneResult result)

このメソッドは、カスタムアダプタ経由で適応したタスクが終了したときに呼び出され、 タスク実行時のresult を渡します。

Worker が finished(bool) シグナルを発すると仮定すると、アダプタは次のようになります:

class WorkerTaskAdapter
{
public:
    void operator()(Worker *task, QTaskInterface *iface) {
        connect(task, &Worker::finished, iface, [iface](bool success) {
            iface->reportDone(toDoneResult(success));
        });
        task->execute();
    }
};

using WorkerTask = QCustomTask<Worker, WorkerTaskAdapter>;

QCustomTaskも参照して ください。

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