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

"Non-existent attached object" error when using Overlay.modal with Popup and custom QuickControls2 style

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.2.2
    • Quick: Controls 2
    • None
    • Qt 6.2.2
      macOS 12.1 (M1 chip)

    Description

      This is a regression experienced when upgrading from Qt 5.15.2 to 6.2.2.

      I have my own style for QtQuickControls 2 as described in the docs. I have a fallback in my qmldir file:

      module QtQuick.Controls.MyStyle
      
      # Does not need to override anything to reproduce the bug
      
      # Fallback
      import QtQuick.Controls.Basic auto
      

      I then try to use the Overlay.modal attached property in a Popup:

      import QtQuick
      import QtQuick.Controls.MyStyle
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          // Code copied from: https://doc.qt.io/qt-6/qml-qtquick-controls2-overlay.html#modal-attached-prop
      
          Popup {
              id: popup
              width: 400
              height: 400
              modal: true
              visible: true
      
              Overlay.modal: Rectangle {
                  color: "#aacfdbe7"
              }
          }
      }
      

      This crashes the app with the following error messages:

      QQmlApplicationEngine failed to load component
      qrc:/ModalDemo/main.qml:21:9: Non-existent attached object
      

       

      I attached a minimal reproduction example project.

      Workaround

      import QtQuick
      import QtQuick.Controls.MyStyle
      import QtQuick.Controls as C
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          // Code copied from: https://doc.qt.io/qt-6/qml-qtquick-controls2-overlay.html#modal-attached-prop
      
          Popup {
              id: popup
              width: 400
              height: 400
              modal: true
              visible: true
      
              C.Overlay.modal: Rectangle {
                  color: "#aacfdbe7"
              }
          }
      }
      

      This works as intended.

      Attachments

        1. ModalDemo.zip
          6 kB
          Niklas Wenzel
        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
            nikwen Niklas Wenzel
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes