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

[REG 5.15.x -> 6.3/6.4/6.5] Mouse Events not accepted on a MouseArea placed inside modal Popup::background

    XMLWordPrintable

Details

    • macOS, Windows
    • dc30e3859 (dev), a493aacc3 (6.5)

    Description

      Please find the attached example code.

      If you run it with Qt5.15.x, you will be able to drag the modal Popup around using mouse.
      And the same does not work correctly if you compile and run with Qt6.3.x, Qt6.4.x or Qt6.5.0

      The Popup can be dragged around with mouse in Qt6 version if we do not set the property `modal: true`

       

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.15
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Button {
              text: "Open"
              onClicked: popup.open()
              anchors.horizontalCenter: parent.horizontalCenter
              y: 10
          }
      
          component CPopup: Popup {
              id: cPopup
      
              width: 400
              height: 300
      
              closePolicy: Popup.NoAutoClose
      
              Component.onCompleted: {
                  x = parent.width / 2 - width / 2
                  y = parent.height / 2 - height / 2
              }
      
              background: Rectangle {
                  id: backgroundRect
                  color: "#505050"
      
                  Rectangle {
                      width: parent.width
                      height: 30
                      color: "#2e2e2e"
      
                      MouseArea {
                          enabled: true
                          propagateComposedEvents: true
                          anchors.fill: parent
                          property point pressedPosition: Qt.point(0, 0)
                          onPressed: function(mouse){
                              console.log("Presssed...")
                              pressedPosition  = Qt.point(mouse.x,mouse.y)
                          }
                          cursorShape: Qt.OpenHandCursor
                          onPositionChanged: function(mouse){
                              console.log("Moving...")
                              var delta = Qt.point(mouse.x - pressedPosition.x, mouse.y - pressedPosition.y)
                              cPopup.x += delta.x;
                              cPopup.y += delta.y;
                          }
                      }
                  }
              }
      
              Button {
                  text: "Close"
                  onClicked: cPopup.close()
                  anchors.bottom: parent.bottom
                  anchors.horizontalCenter: parent.horizontalCenter
              }
          }
      
          CPopup {
              id: popup
              modal: true // commenting out this line will enable us to drag around
          }
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              santhoshkumar Santhosh Kumar Selvaraj
              holo-pk Arun ParolKundan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes