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

QQmlApplicationEngine/QWidget::createWindowContainer Interface drift

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9.1, 5.10.1, 5.11.1, 5.12.4, 5.13.0
    • None
    • Qt 5.9.1 : MinGW32
      Qt 5.10.1 : MinGW32
      Qt 5.11.1 : MinGW32
      Qt 5.12.1 : MinGW32
      Qt 5.13.1 : MinGW32
    • Windows

    Description

       

      // main.cpp
      #include <QtQml/QQmlApplicationEngine>
      #include <QtWidgets/QApplication>
      #include <QtQuick/QQuickWindow>
      #include <QtWidgets>
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          QQmlApplicationEngine engine;
          engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
      
          QWindow *qmlWindow = qobject_cast<QWindow*>(engine.rootObjects().at(0));
          QWidget *container = QWidget::createWindowContainer(qmlWindow);
          container->setMinimumSize(qmlWindow->size());
          QWidget *widget = new QWidget();
      
          QGridLayout *grid = new QGridLayout(widget);
          grid->addWidget(container,0,0);
          grid->addWidget(new QPushButton(widget),1,0);
      
          widget->show();
      
          return app.exec();
      }

       

      // main.qml
      import QtQuick 2.0
      import QtQuick.Layouts 1.3
      import QtQuick.Controls 2.2
      import QtQuick.Controls.Material 2.1
      import QtQuick.Controls.Universal 2.1
      import Qt.labs.settings 1.0
      
      ApplicationWindow {
          visible:true
          color:"blue"
          header: ToolBar {
              RowLayout {
                  anchors.fill: parent
                  ToolButton {
                      text: qsTr("‹")
                      onClicked: stack.pop()
                  }
                  Label {
                      text: "Title"
                      elide: Label.ElideRight
                      horizontalAlignment: Qt.AlignHCenter
                      verticalAlignment: Qt.AlignVCenter
                      Layout.fillWidth: true
                  }
                  ToolButton {
                      text: qsTr("⋮")
                      onClicked: menu.open()
                  }
              }
          }
      
          StackView {
              id: stack
              anchors.fill: parent
          }
      }
      
      
      

      I don't know this problem it's about

      QQmlApplicationEngine

       or

      QWidget::createWindowContainer

      .

      I want to embed QML into QMainWindow. When I run the main.cpp , the QML will Interface drift in QMainWindow's layout like as error1.gif and error2.gif.

       ( 我想把QML界面嵌入到QMainWindow 中 , 但是会发生附件 error1.gif 和   error2.gif 中的错误, 我不知道是QQmlApplicationEngine 的问题还是 QWidget::createWindowContainer 的问题)

       

      Attachments

        1. error1.gif
          error1.gif
          1.96 MB
        2. error2.gif
          error2.gif
          1.94 MB
        3. image-2020-01-10-03-11-09-824.png
          image-2020-01-10-03-11-09-824.png
          1.19 MB
        4. image-2020-01-10-03-30-00-912.png
          image-2020-01-10-03-30-00-912.png
          56 kB
        5. image-2020-01-10-03-38-26-749.png
          image-2020-01-10-03-38-26-749.png
          45 kB
        6. qtbug67698_min.zip
          2 kB
        7. qtbug67698.zip
          163 kB
        8. same_error.gif
          same_error.gif
          1.54 MB
        9. test_QQmlApplicationEngine-master.rar
          149 kB

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              lin-jh 江函 林
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes