-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
executable file
·42 lines (37 loc) · 1.45 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
#include <VPApplication>
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QQmlEngine> // for connect()
#include <QCoreApplication> // for connect()
#include <QtQml> // for qmlRegisterType<>()
#include "game.h"
#include "clientcard.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
VPApplication vplay;
QQmlApplicationEngine engine;
vplay.initialize(&engine);
// QQuickView view;
qDebug()<<"From main thread: "<<QThread::currentThreadId();
qRegisterMetaType<glaze::ClientCard*>("ClientCard*");
qRegisterMetaType<glaze::ClientCard**>("ClientCard**");
qRegisterMetaType<glaze::ClientCardModel*>("ClientCardModel*");
// qRegisterMetaType<glaze::Buffer>("Buffer");
glaze::Game _game;
glaze::mainGame = &_game;
if(!glaze::mainGame->Initialize())
return 0;
// context property should come before you set qml source
engine.rootContext()->setContextProperty("clientField",&glaze::mainGame->dField);
engine.rootContext()->setContextProperty("game",glaze::mainGame);
engine.rootContext()->setContextProperty("duelInfo",&glaze::mainGame->dInfo);
vplay.setMainQmlFileName(QStringLiteral("qml/main.qml"));
engine.load(QUrl(vplay.mainQmlFileName()));
// view.setSource(QUrl("qrc:/main.qml"));
// view.show();
// view.showFullScreen();
// QObject::connect(engine, SIGNAL(quit()), QApplication::instance(), SLOT(quit()));
return app.exec();
}