Issue
I have a subclass of QGraphicsItem. By default, QGraphicsItem only receives mouseMoveEvents if the pointer is within the boundingRect of the item AND a mousePressEvent has also happened.
I want this subclass to receive ALL mouseMoveEvents that occur within the QGraphicsScene that it's a member of (preferably in item coordinates). Is this possible?
Solution
Yes. You can use QGraphicsItem::grabMouse()
to ensure that you get all mouse events. If you do so, then Qt promises the following:
This item will receive all mouse events for the scene until any of the following events occurs:
- The item becomes invisible
- The item is removed from the scene
- The item is deleted
- The item call ungrabMouse()
- Another item calls grabMouse(); the item will regain the mouse grab when the other item calls ungrabMouse().
Answered By - cgmb
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.