forked from mastermune/InputRedirectionClient-Qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
35 lines (30 loc) · 919 Bytes
/
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
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
#include "mainwidget.h"
#include "gpmanager.h"
#include "global.h"
#include <QTimer>
#include <QThread>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
GamepadMonitor m(&w);
w.show();
QThread* thread = new QThread();
QTimer timer;
timer.setInterval(20);
timer.moveToThread(thread);
worker = new Worker();
worker->moveToThread(thread);
QObject::connect(thread, SIGNAL (started()), &timer, SLOT (start()));
QObject::connect(worker, SIGNAL (finished()), thread, SLOT (quit()));
QObject::connect(thread, SIGNAL (finished()), thread, SLOT (deleteLater()));
QObject::connect(worker, SIGNAL (finished()), worker, SLOT (deleteLater()));
QObject::connect(&timer, SIGNAL (timeout()), worker, SLOT(sendFrame()));
thread->start();
a.exec();
worker->closeThread();
return 0;
}