On 8 May 2014, at 9:06 AM, Andreas Cord-Landwehr wrote:

> Hi, I am looking for a proper way on how to apply a mouse press-release 
> operation on two QtQuick objects. For simplicity, say I have two rectangles 
> on the QtQuick scene. Now I want to press the mouse at one of them and 
> release it at the other rectangle. By this, I want to listen to the onPressed 
> signal of the first and to the onReleased signal of the second rectangle. 
> (the idea behind: I create a connection between both objects)
>  
> My current approach was to use MouseArea items filling each rectangle. Yet, 
> when pressing the mouse at the first rectangle and releasing at at the other, 
> I only get pressed(MouseEvent) and released(MouseEvent) signals from the 
> first rectangle, i.e. the rectangle where I started the press.
>  
> What would be a correct way to do this?

That doesn't work because QQuickWindow keeps track of the mouse grabber: the 
item which accepted the press will be the one which gets all subsequent mouse 
events up to and including the release.  There is the concept of stealing mouse 
events from a child item, e.g. Flickable can still flick even if you happened 
to start with your finger pressing a MouseArea inside the Flickable; if you 
drag far enough then Flickable will "steal" the grabber status for itself.  But 
MouseArea doesn't do that.  So you will probably need to use one MouseArea, 
implement onPositionChanged (which will be called only when the mouse button is 
pressed, unless you enable hover) and pay attention to the position (mouse.x 
and/or mouse.y) to see whether you crossed over the boundary where you would 
have wanted two MouseAreas side-by-side.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to