1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include "worker.hxx" #include "controller.hxx" Controller::Controller() { Worker* worker = new Worker{}; worker->moveToThread(&thread); connect(&thread, &QThread::finished, worker, &QObject::deleteLater); thread.start(); } Controller::~Controller() { thread.quit(); thread.wait(); }