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. Mouse Event Drag Release
Qt 6.11 is out! See what's new in the release blog

Mouse Event Drag Release

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 1.8k 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.
  • saitejS Offline
    saitejS Offline
    saitej
    wrote on last edited by
    #1

    Hi

    I am using MouseArea of a MapQuickItem for dragging the item.

     MouseArea{
    
            anchors.fill:  parent
            id: _markerMouseArea
            drag.target: parent
            drag.minimumX:  0;
            drag.minimumY:  0;
            preventStealing: true
            hoverEnabled: true
            cursorShape: Qt.OpenHandCursor
         
    
            acceptedButtons:  Qt.LeftButton
    
    
    
            onReleased: {
                console.log("Released")
                updateCoordinate()
            }
    
    
    
        }
    

    Many times the mouse release event is not being recognized and hence misses to call the function updateCoordinate() but the object is in the new position. What could be the issue?

    Also, the cursor shape does not change when the object is interacted.

    Thanks!

    1 Reply Last reply
    0
    • RajeeshRaveendranR Offline
      RajeeshRaveendranR Offline
      RajeeshRaveendran
      wrote on last edited by
      #2

      Hi Saitej,

      I got a similiar issue when I tried to do some thing on onReleased event of MouseArea. In my case I pressed mouse area and started doing my stuff.
      But in between I lost the focus from mouse area (By some other action eg:- Alt + tab key pressed) and missed to get the onReleased event.
      From that I understood that OnReleased called only if I pressed/dragged and released the mouse normally without any interference like focus change by other means. So I changed my code by using onPressedChanged instead of onReleased.

      onReleased: { /// No guarantee to get invoked always when i released the mouse(unless it has focus)
      }

      onPressedChanged: {
      if(pressed) {
      /// Mouse is in pressed state.
      }
      else {
      /// Mouse released. Either by user released the mouse button or by focus change to any other control.
      /// Here it is ensured that release will executed.
      }
      }

      1 Reply Last reply
      1
      • saitejS Offline
        saitejS Offline
        saitej
        wrote on last edited by
        #3

        Thanks a lot man!!

        It seems to work better than before but I need to give it more tests.

        RajeeshRaveendranR 1 Reply Last reply
        0
        • saitejS saitej

          Thanks a lot man!!

          It seems to work better than before but I need to give it more tests.

          RajeeshRaveendranR Offline
          RajeeshRaveendranR Offline
          RajeeshRaveendran
          wrote on last edited by
          #4

          @saitej You are welcome.

          1 Reply Last reply
          0

          • Login

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