-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
44 lines (32 loc) · 1.34 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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QQmlContext>
#include "headers/articlemodel.h"
#include "headers/windowloader.h"
#include "headers/user.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
ArticleModel articleModel;
// articleModel.putExampleArticles();
WindowLoader windowLoader;
User user;
// user.authenticate("[email protected]", "abcdefgh");
// QTextStream(stdout) << "Authenticated?: " << user.isAuthenticated()<< "\n";
// user.authenticate("[email protected]", "abcdefghij");
// QTextStream(stdout) << "Authenticated?: " << user.isAuthenticated()<< "\n";
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("articleModel", QVariant::fromValue(&articleModel));
engine.rootContext()->setContextProperty("windowLoader", &windowLoader);
engine.rootContext()->setContextProperty("user", QVariant::fromValue(&user));
// const QUrl url(u"qrc:/Blog/main.qml"_qs);
const QUrl url(QStringLiteral("qrc:/Blog/qml/loader.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}