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. Notify release signal to mouse area after go outside (Solve)
Forum Updated to NodeBB v4.3 + New Features

Notify release signal to mouse area after go outside (Solve)

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 2 Posters 2.2k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    Tân Ngọc Đỗ
    wrote on last edited by
    #1

    Hello,

    I have a problem . When I keep pressing a rectangle and drag it (the rectange keeps it position but the mouse go out of the rectange) . After dropping into desktop ; the mouse area of rectange can not recognize the onRelease handle (of course) . Is there anyway that we can notify mouse area the we don't want it remember the release for the next time(manually release the mouse with code) ? Because when I return to the application, I press on another rectangle, the old rectangle still receive onPress hanlde .

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tân Ngọc Đỗ
      wrote on last edited by
      #2

      When I press and hold the mouse on a rectange and go out of it. I release, onRelease is called. But with Drag and drop, this handle can not be called . It makes me confused

      1 Reply Last reply
      0
      • p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

        Hi,

        Can you show a small working example which explains the problem ?

        157

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Tân Ngọc Đỗ
          wrote on last edited by
          #4

          I have 2 rectangles :

          @
          Rectangle {
          id: rect1
          MouseArea {
          onPositionChanged: DraggingClass.DragProcessing(this) // I used this class to process dragging for rect1

          onReleased: print("Rect1 onrelease")
          }
          }

          Rectangle {
          id: rect2
          MouseArea {
          onPositionChanged: DraggingClass.DragProcessing(this) // I used this class to process dragging for rect2

          onReleased: print("Rect2 onrelease")
          }
          }

          @

          If I drag and drop rect1; after that, I press on rect2 , "Rect1 onrelease" will be printed . It's a wrong result because I want rect1.onRelease will be called after I release the mouse on drag and drop rect1

          1 Reply Last reply
          0
          • p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #5

            Are the two rectangles overlapping ?
            Is "Rect2 onrelease" printed when you release rect2 ?

            Can you give a complete working example ? It's hard to guess what's actually going on with the code pasted above.

            157

            1 Reply Last reply
            0
            • T Offline
              T Offline
              Tân Ngọc Đỗ
              wrote on last edited by
              #6

              Hello, Those rectangles are separated , they are not overlapped .

              Because the source code is too long, I just can give a ideal :

              In the normal case:

              @
              Rectangle {
              id: rect1
              MouseArea {
              onPositionChanged: // I leave this empty

              onReleased: print("Rect1 onrelease")
              }  
              

              }

              Rectangle {
              id: rect2
              MouseArea {
               onPositionChanged: //  I leave this empty
               
               
              onReleased: print("Rect2 onrelease")
              }  
              

              }

              @

              When I keep pressing in one of two rectangle and release the mouse outsite the application . Onrelease is always called .

              with drag and drop :
              @onPositionChanged: DraggingClass.DragProcessing(this) // @

              In function DragProcessing(this) : i just create a QDrag(this)
              to support drag and drop .

              My concern is: maybe Drag and Drop using C++ steal my mouse release ?

              1 Reply Last reply
              0
              • p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #7

                Have you tried using "QML Drag":http://qt-project.org/doc/qt-5/qml-qtquick-drag.html#details to see if the problem persists ? I have never used Drag and Drop QML items from C++.

                157

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  Tân Ngọc Đỗ
                  wrote on last edited by
                  #8

                  Hello,

                  QML Drag is not good ,up to now. I can't drag and drop to external application and I have my own purpose to use C++ . I have just figured the solution . I just use QQuickItem::ungrabMouse() to ungrab the mouse on My rectangle in C++ code . So, after I drop the rectangle , the mouse won't affect on the old rectangle .

                  Anyways, thanks for your help .

                  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