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

[REG 5.11->5.12] Deleting items from a QQuickView while it's shown confuses mouse handling

    XMLWordPrintable

Details

    • Linux/X11, Linux/Other display system
    • 402efef57bb6a04ad778d3139100becc2cba31eb (qt/qtbase/5.12)

    Description

      Consider:

      #include <QtCore/qtimer.h>
      #include <QtGui/qguiapplication.h>
      #include <QtQml/qqmlengine.h>
      #include <QtQuick/qquickview.h>
      #include <QtQuick/qquickitem.h>
      
      int main(int argc, char ** argv)
      {
          const QByteArray qml =
                  "import QtQuick 2.3\n"
                  "TextEdit {\n"
                  "    text: 'Switch Delegate'\n"
                  "}";
      
          QGuiApplication app(argc, argv);
      
          QQmlEngine engine;
      
          QQmlComponent component(&engine);
          component.setData(qml, QUrl());
      
          QQuickItem *contentItem = qobject_cast<QQuickItem *>(component.create());
          QQuickView window(&engine, nullptr);
          window.setContent(QUrl(), &component, contentItem);
          window.show();
      
          QTimer::singleShot(100, [&](){
              // window.close() here and it works
              for (QQuickItem *oldItem : window.contentItem()->childItems())
                  delete oldItem;
              window.close();
      
              QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
              item->setParentItem(window.contentItem());
              window.setVisible(true);
          });
      
          return app.exec();
      }
      

      With 5.11.2 this works nicely, replacing the contents of the scene after 100ms and the TextEdit still gains focus when you click it. With 5.12 it replaces the contents, but the TextEdit is not focused anymore when you click it.

      If you close the window first, before changing the contents, the TextEdit still works after re-opening it. If you keep the window open the whole time it also works. If you don't delete the contents but merely unparent them, it also works.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-70957
          # Subject Branch Project Status CR V

          Activity

            People

              ulherman Ulf Hermann
              ulherman Ulf Hermann
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes