Debian Codegraph @

test cases/frameworks/40 qt qml/QmlMain.cpp

raw
1 #include <QGuiApplication>
2 #include <QQmlApplicationEngine>
3 #include <QDebug>
4
5 //extern type registration
6 extern void qml_register_types_My_Module6();
7
8 int main(int argCount, char* argVector[])
9 {
10 //register resources from static libraries
11 Q_INIT_RESOURCE(My_Module6);
12 Q_INIT_RESOURCE(qmlcache_My_Module6);
13 qml_register_types_My_Module6();
14
15 //don't require a grapical environment to run the test
16 qputenv("QT_QPA_PLATFORM", "offscreen");
17
18 QGuiApplication app(argCount, argVector);
19 QQmlApplicationEngine engine;
20
21 QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, [](QObject *object, const QUrl &url){
22 if (object == nullptr) {
23 qFatal("unable to load scene");
24 }
25 });
26
27 engine.addImportPath("qrc:///qt/qml");
28 engine.addImportPath("qrc:///test");
29 engine.load("qrc:///qt/qml/My/Module0/Main.qml");
30 return app.exec();
31 }