Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-29873

QQuickView cannot launch ApplicationWindow

    XMLWordPrintable

Details

    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();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            aalpert Alan Alpert
            carochao Caroline Chao (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes