Details
-
Suggestion
-
Resolution: Invalid
-
P1: Critical
-
None
-
None
Description
QQuickView cannot currently be used to launch a qml file with an ApplicationWindow as root item.
The current workaround is described in:
"<git_clone_qtdesktopcomponents>/examples/ApplicationTemplate"
#include <QtWidgets/QApplication> #include <QtQml> #include <QtQuick/QQuickView> int main(int argc, char *argv[]) { QApplication app(argc, argv); QQmlEngine engine; QQmlComponent component(&engine); component.loadUrl(QUrl("qrc:/qml/main.qml")); if ( !component.isReady() ) { qWarning("%s", qPrintable(component.errorString())); return -1; } QObject *topLevel = component.create(); QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel); if ( !window ) { qWarning("Error: Your root item has to be a Window."); return -1; } window->show(); return app.exec(); }