blob: 4962072f6b16e8e40413cf9b9ef96774b19fabbd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <QQmlApplicationEngine>
#include "worker.hxx"
#include "controller.hxx"
Controller::Controller(QObject* parent) : QObject{parent}
{
Worker* worker = new Worker{parent};
worker->moveToThread(&thread);
connect(&thread, &QThread::finished, worker, &QObject::deleteLater);
auto engine = dynamic_cast<QQmlApplicationEngine*>(parent);
auto rootObjects = engine->rootObjects();
auto appWindow = rootObjects[0];
connect(appWindow, SIGNAL(logIn(QString, QString)),
worker, SLOT(logIn(QString, QString)));
thread.start();
}
Controller::~Controller()
{
thread.quit();
thread.wait();
}
|