QtTaskTree::QTaskInterface Class
class QtTaskTree::QTaskInterfaceQTaskInterface es una clase de ayuda utilizada para adaptar la interfaz de una tarea personalizada. Más...
| Cabecera: | #include <qtasktree.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS TaskTree)target_link_libraries(mytarget PRIVATE Qt6::TaskTree) |
| qmake: | QT += tasktree |
| Desde: | Qt 6.11 |
| Hereda: | QObject |
Nota: Todas las funciones de esta clase son reentrantes.
Funciones Públicas
| void | reportDone(QtTaskTree::DoneResult result) |
Funciones Protegidas Reimplementadas
| virtual bool | event(QEvent *event) override |
Descripción detallada
Se espera que el tipo personalizado Adapter de la plantilla QCustomTask<Task, Adapter, Deleter> tenga la siguiente forma, al adaptar la tarea Worker:
class WorkerTaskAdapter { public: void operator()(Worker *task, QTaskInterface *iface) { ... } }; using WorkerTask = QCustomTask<Worker, WorkerTaskAdapter>;
Documentación de funciones miembro
[override virtual protected] bool QTaskInterface::event(QEvent *event)
Reimplementa: QObject::event(QEvent *e).
void QTaskInterface::reportDone(QtTaskTree::DoneResult result)
Este método debe ser llamado cuando la tarea adaptada a través del adaptador personalizado finaliza, pasando el result de la ejecución de la tarea.
Asumiendo que el Worker emite una señal finished(bool), el adaptador puede tener el siguiente aspecto:
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>;
Ver también 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.