Notify release signal to mouse area after go outside (Solve)
-
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 .
-
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
-
Hi,
Can you show a small working example which explains the problem ?
-
I have 2 rectangles :
@
Rectangle {
id: rect1
MouseArea {
onPositionChanged: DraggingClass.DragProcessing(this) // I used this class to process dragging for rect1onReleased: print("Rect1 onrelease")
}
}Rectangle {
id: rect2
MouseArea {
onPositionChanged: DraggingClass.DragProcessing(this) // I used this class to process dragging for rect2onReleased: 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
-
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.
-
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 emptyonReleased: 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 ?
-
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++.
-
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 .