QTaskInterface Class
QTaskInterface is a helper class used when adapting custom task's interface. More...
| Header: | #include <qtasktree.h> |
| Inherits: | QObject |
Note: All functions in this class are reentrant.
Public Functions
| void | reportDone(QtTaskTree::DoneResult result) |
Detailed Description
The custom Adapter type of the QCustomTask<Task, Adapter, Deleter> template is expected to have the following form, when adapting Worker task:
class WorkerTaskAdapter { public: void operator()(Worker *task, QTaskInterface *iface) { ... } }; using WorkerTask = QCustomTask<Worker, WorkerTaskAdapter>;
Member Function Documentation
void QTaskInterface::reportDone(QtTaskTree::DoneResult result)
This method should be called when the task adapted via custom adapter is finished, passing the result of the task execution.
Assuming the Worker emits a finished(bool) signal, the adapter may look like:
class WorkerTaskAdapter { public: void operator()(Worker *task, QTaskInterface *iface) { connect(task, &Worker::finished, iface, [iface](bool success) { iface->reportDone(QtTaskTree::toDoneResult(success)); }); task->execute(); } }; using WorkerTask = QCustomTask<Worker, WorkerTaskAdapter>;
See also QCustomTask.
Copyright © The Qt Company Ltd. and other contributors. 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.