solitare/main.cpp
ItsDrike 883d766dc3
Register QObject classes as QML elements via macros
Using manual registration with qmlRegisterType (or
qmlRegisterUncreatableType) isn't ideal, because Qt Creator can't pick
up on it. When using the macros, autocompletion & unknown type warnings
in the code disappear.
2024-12-03 15:05:30 +01:00

30 lines
687 B
C++

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "gamestate.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
GameState gameState;
gameState.dealCards();
gameState.drawNextCard();
gameState.drawNextCard();
gameState.drawNextCard();
engine.rootContext()->setContextProperty("gameState", &gameState);
engine.loadFromModule("Solitare", "Main");
return app.exec();
}