How I do to run Maroon In Trouble example?
-
Hi. Is there anyone who can run Maroon in Trouble? I downloaded the source code from examples in Qt Creator and I changed the code from main.cpp to the next (the original code doesn't find shared.h):
/*#include "../../shared/shared.h" DECLARATIVE_EXAMPLE_MAIN(demos/maroon/maroon)*/ #include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/demos/maroon/maroon.qml"))); return app.exec(); }
I copied the code from the documentation file by file and it still not working.
I use Qt-Creator 3.4.1 and Qt 5.4.2 on Kubuntu 14.04. What am I doing bad?
-
Hi @Cold_Distance,
QQmlApplicationEngine
unlikeQQuickView
does not automatically create a root window which means you have to create aWindow
orApplicationWindow
in the QML file.
The file which you are loadingmaroon.qml
does not contain aWindow
orApplicationWindow
as root but contains andItem
as root. SoQQmlApplicationEngine
will fail here.
To rectify it you will either need to addWindow
to QML OR useQQuickView
load that QML.
UsingQQuickView
instead ofQQmlApplicationEngine
in this case will be faster with minimal changes.