/
main.cpp
60 lines (49 loc) · 1.27 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* File: main.cpp
* Author: danijel.slivka
*
* Created on January 30, 2016, 5:26 PM
*/
#include <QCoreApplication>
#include <QObject>
#include <QThread>
class WorkerThread : public QThread
{
Q_OBJECT
void run() Q_DECL_OVERRIDE {
QString result;
/* ... here is the expensive or blocking operation ... */
emit resultReady(result);
}
signals:
void resultReady(const QString &s);
};
class Controller : public QThread
{
Q_OBJECT
public:
Controller();
~Controller() {
}
public slots:
void handleResults(const QString &);
void startWorkInAThread();
};
void Controller::startWorkInAThread()
{
WorkerThread *workerThread = new WorkerThread(this);
connect(workerThread, &WorkerThread::resultReady, this, &Controller::handleResults);
connect(workerThread, &WorkerThread::finished, workerThread, &QObject::deleteLater);
workerThread->start();
}
int main(int argc, char *argv[]) {
// initialize resources, if needed
// Q_INIT_RESOURCE(resfile);
QCoreApplication app(argc, argv);
Controller kontroler;
kontroler.startWorkInAThread();
// create and show your widgets here
//setting for remote repository
return app.exec();
//testing the repository
}