From c8891b50d1f30c7c07bf96f8eaf2e1002ce573b8 Mon Sep 17 00:00:00 2001 From: Erik Prabowo Kamal Date: Thu, 29 Aug 2019 15:30:00 +0800 Subject: Set up a way for the thread to quit --- controller.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 controller.cxx (limited to 'controller.cxx') diff --git a/controller.cxx b/controller.cxx new file mode 100644 index 0000000..d1271b9 --- /dev/null +++ b/controller.cxx @@ -0,0 +1,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(); +} -- cgit v1.2.3