Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. MouseArea not getting released event when occluded
Forum Update on Monday, May 27th 2025

MouseArea not getting released event when occluded

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 257 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alcinos
    wrote on last edited by alcinos
    #1

    Hi,

    I have a MouseArea whose OnPressed method triggers a chain of events, which eventually leads to the creation an object which masks the mouseArea (that is, the created object is "between" the cursor and the mouseArea, depthwise).

    The problem is that the release event of the mouse will not be propagated back to the mouseArea, hence any further mouse press and mouse move will not behave correctly, as the pressed flag will not be reset to false

    After some interactions, the user can move or delete the created top object, which will make the mouseArea available for events again, but since the pressed flag is still on, any further mouse click will not produce any effect.

    Is this a bug? How can I workaround this?
    I tried sending a released() event from the OnPressed function of the mouseArea, but couldn't figure out how to create a fake mouse event (since the fields seem to be read-only...). Passing the mouse event received by the OnPressed doesn't work (probably because the button is still set). The cancelled() event doesn't cut it either.

    1 Reply Last reply
    0
    • Shrinidhi UpadhyayaS Offline
      Shrinidhi UpadhyayaS Offline
      Shrinidhi Upadhyaya
      wrote on last edited by
      #2

      Hi @alcinos , if you give some sample code,it would help us to understand better and get to know what you want and where it is failing.

      Here is a sample code from what i have understood:-
      There are 2 Rectangles rect1 and rect2, rect2 is not visible,on pressing rect1 a timer is started which on triggered will make the rect2 visible and on releasing the mouse,you will get a console print that is "Rect1 Released"

      ```
       Timer {
              id: dummyTimer
      
              interval: 2000
              running: false
      
              onTriggered: {
                  console.log("Timer Triggered")
                  rect2.visible = true
              }
          }
      
          Rectangle {
              id: rect1
      
              height: 100
              width: 100
              color: "red"
              anchors.centerIn: parent
      
              MouseArea {
                  anchors.fill: parent
      
                  onPressed: {
                      console.log("Rect 1 Pressed")
                      dummyTimer.start()
                  }
      
                  onReleased: {
                      console.log("Rect 1 Released")
                  }
              }
          }
      
      
          Rectangle {
              id: rect2
      
              height: 100
              width: 100
              color: "green"
              anchors.centerIn: parent
              visible: false
          }
      

      Shrinidhi Upadhyaya.
      Upvote the answer(s) that helped you to solve the issue.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved