-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
30 lines (22 loc) · 778 Bytes
/
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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQmlEngine>
#include "myobject.h"
#include "model.h"
#include <QtQml>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
AnimalModel model;
model.addAnimal(Animal("Wolf", "Medium"));
model.addAnimal(Animal("Polar bear", "Large"));
model.addAnimal(Animal("Quoll", "Small"));
qmlRegisterType<NameCounter>("dk.winkler.qml.NameCounter", 1, 0, "NameCounter");
QQmlApplicationEngine engine;
NameCounter morten("Morten");
engine.rootContext()->setContextProperty("morten", &morten);
engine.rootContext()->setContextProperty("myModel", &model);
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
return app.exec();
}