<SOLVED> QQuickWindow not shown
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("qml/myTEst/main.qml")); //Create an object instance from this component QObject* myComponent = component.create(); QQuickWindow* window = qobject_cast<QQuickWindow *>(myComponent); window->show(); return app.exec();
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.