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

Disabled MouseArea containsMouse is true if made visible when mouse is over it



    • 8f1857f907153c4a98c73d572ea76c2b7ca33b5d (qt/qtdeclarative/5.14)


      When a MouseArea is made visible, containsMouse is set to true if the mouse pointer is inside the MouseArea, even if the MouseArea is not enabled.

      Test with the following reproduction code in qmlscene.

      A Rectangle with a disabled MouseArea filling it is shown/hidden every 3000ms. If the mouse is inside the Rectangle when it is made visible, then mouseArea.containsMouse is true. I would expect that containsMouse is false in this case.

      containsMouse does not change to false when moving the mouse out of the Rectangle in this state.

      If the mouse is outside of the Rectangle when it is shown, then containsMouse will not change to true when moving the mouse over the Rectangle (which is as expected).

      The problem also occurs if enabled: false is moved from the MouseArea to the Rectangle.

      import QtQuick 2.4
      import QtQuick.Controls 1.3
      import QtQuick.Window 2.11
      Window {
          id: root
          width: 500
          height: 500
          Rectangle {
              id: rect
              width: 400
              height: 400
              anchors.centerIn: parent
              color: mouseArea.containsMouse ? "red" : "green"
              MouseArea {
                  id: mouseArea
                  anchors.fill: parent
                  enabled: false
                  hoverEnabled: true
          Timer {
              id: rectShowHideTimer
              interval: 3000
              repeat: true
              running: true
              onTriggered: rect.visible = !rect.visible

      Tested with both 5.11.2 and 5.13.0 on Ubuntu 18.04.


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



            qt.team.quick.subscriptions Qt Quick and Widgets Team
            partridge Stian Pedersen
            0 Vote for this issue
            2 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes