-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
51 lines (43 loc) · 1.79 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
#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"
#include <QtCore/QUrl>
#include <QQmlEngine>
#include <QUrl>
#include <QtQml>
#include "ticker.h"
#include "bridge.h"
#include <chrono>
#include <thread>
#include <QQuickItem>
int main(int argc, char *argv[])
{
// Setup main event loop for the GUI.
QGuiApplication app(argc, argv);
app.setOrganizationName("UiO Project");
app.setOrganizationDomain("github.com/Tarostar/QMLGalaxyPortal");
app.setApplicationName("Galaxy Portal");
// Setup background thread and bridge interface between thread and QML.
/*Bridge* bridge = new Bridge();
QThread* thread = new QThread;
Ticker* ticker = new Ticker();
ticker->moveToThread(thread);
bridge->setTicker(ticker);
// Connect signals and slots.
QObject::connect(ticker, SIGNAL(tick()), bridge, SLOT(tick()), Qt::BlockingQueuedConnection);
QObject::connect(thread, SIGNAL(started()), ticker, SLOT(mainThread()));
QObject::connect(&app, SIGNAL(aboutToQuit()), bridge, SLOT(killTicker()));
QObject::connect(&app, SIGNAL(aboutToQuit()), thread, SLOT(quit()));
QObject::connect(&app, SIGNAL(aboutToQuit()), ticker, SLOT(deleteLater()));
QObject::connect(&app, SIGNAL(aboutToQuit()), thread, SLOT(deleteLater()));
QObject::connect(&app, SIGNAL(aboutToQuit()), bridge, SLOT(deleteLater()));
thread->start();*/
// Setup QQuickView window for displaying Qt Quick GUI and connect with background thread through the bridge interface.
QtQuick2ApplicationViewer viewer;
//viewer.rootContext()->setContextProperty("Bridge", bridge);
viewer.setMainQmlFile(QStringLiteral("qml/QMLGalaxyPortal/main.qml"));
viewer.showExpanded();
// Execute main event loop.
int nResult = app.exec();
// Exit.
return nResult;
}