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?


  • Moderators

    Hi @Cold_Distance,
    QQmlApplicationEngine unlike QQuickView does not automatically create a root window which means you have to create a Window or ApplicationWindow in the QML file.
    The file which you are loading maroon.qml does not contain a Window or ApplicationWindow as root but contains and Item as root. So QQmlApplicationEngine will fail here.
    To rectify it you will either need to add Window to QML OR use QQuickView load that QML.
    Using QQuickView instead of QQmlApplicationEngine in this case will be faster with minimal changes.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.