forked from zel1b08a/QmlTest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (34 loc) · 1.72 KB
/
main.cpp
File metadata and controls
41 lines (34 loc) · 1.72 KB
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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "client.h"
#include "bank.h"
#include "bankmodel.h"
#include "configmodel.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
qRegisterMetaType<QAbstractSocket::SocketError>();
qRegisterMetaType<QAbstractSocket::SocketState>();
qRegisterMetaType<Bank*>();
qmlRegisterType<BankModel>("Config", 1, 0, "BankModel");
qmlRegisterType<ConfigModel>("Config", 1, 0, "ConfigModel");
qmlRegisterUncreatableType<Bank>("Config", 1, 0, "Bank", QStringLiteral("Don't!"));
Client client;
ConfigModel cfg;
cfg.setBanks(QList<Bank*>()
<< new Bank(QVector<Coefficient>({ Coefficient { 11 }, Coefficient { 21 }, Coefficient { 31 }, Coefficient { 41 } }))
<< new Bank(QVector<Coefficient>({ Coefficient { 12 }, Coefficient { 22 }, Coefficient { 32 }, Coefficient { 42 } }))
<< new Bank(QVector<Coefficient>({ Coefficient { 13 }, Coefficient { 23 }, Coefficient { 33 }, Coefficient { 43 } }))
<< new Bank(QVector<Coefficient>({ Coefficient { 14 }, Coefficient { 24 }, Coefficient { 34 }, Coefficient { 44 } }))
<< new Bank(QVector<Coefficient>({ Coefficient { 15 }, Coefficient { 25 }, Coefficient { 35 }, Coefficient { 45 } }))
);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty(QStringLiteral("cfg"), &cfg);
engine.rootContext()->setContextProperty(QStringLiteral("client"), &client);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}