Important: Please read the Qt Code of Conduct -

<SOLVED> QQuickWindow not shown

  • Hello,

    I am testing stuff but I just can't be able to understand why the following code does not work:

    int main(int argc, char *argv[])
    QGuiApplication app(argc, argv);

    QQmlEngine engine;
    //The QQmlComponent class encapsulates a QML component definition
    QQmlComponent component( &engine, QUrl::fromLocalFile&#40;"qml/myTEst/main.qml"&#41;&#41;;
    //Create an object instance from this component
    QObject* myComponent = component.create();
    QQuickWindow*  window = qobject_cast<QQuickWindow *>(myComponent);
    return app.exec&#40;&#41;;


    In the end when I try to run no window is displayed and the App. exits with:
    "The program has unexpectedly finished
    app.exe exited with code -1073741819"

    Don't know what I am doing wrong.

  • I think I solved it, the problem is related to the .pro file.

    I needed to add the line: QT += core gui

    And re-run Qmake, and is linking and running.

Log in to reply