[Interest] QGraphicsItem does not become a mouse grabber

Dmitrii Volosnykh dmitrii.volosnykh at gmail.com
Tue Mar 11 12:24:23 CET 2014


Also I expect to recieve mouse release event (plus, any mouse moves between
press and release events as well) even if item was not explicitly set as a
mouse grabber.


2014-03-11 13:36 GMT+04:00 Dmitrii Volosnykh <dmitrii.volosnykh at gmail.com>:

> I'd like my custom item to become an explicit mouse grabber on mouse press
> event. I call grabMouse() inside mousePressEvent() handler, but it does not
> receive any consecutive mouse move and release events (imagine, I try to
> drag this item).
>
> As far as I can see from QGraphicsScene's sources
> QGraphicsScenePrivate::mousePressEventHandler() forwards mouse press event
> to the item under cursor, making it implicit mouse grabber a priori. After
> this mouse event was handled by the target item, the former one releases
> mouse grabber state. While in general this seems to be okay, I expect this
> custom item to keep mouse grabber state when it was set explicitly. Indeed,
> what actually grabMouse() does, being called from mousePressEvent(), is
> updates lastMouseGrabberItemHasImplicitMouseGrab flag to false. So, I
> guess, ungrabMouse() should be called only in case item is still an
> implicit mouse grabber.
>
> Does this suggestion make sense? Should the current behaviour be
> considered as a false one?
>
> Regards,
> Dmitrii.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140311/489d91c6/attachment.html>


More information about the Interest mailing list