I have a QGraphicsScene which uses a subclass of QGraphicsItem called ModuleItem. I want to be able to click and drag the corner of the ModuleItem to resize it. I have implemented this using mousePressEvent, mouseReleaseEvent, and mouseMoveEvent. Specifically, when the corner of the ModuleItem is pressed, a field called "resizing" is set to true and the press event is accepted. When resizing is set to true, mouseMoveEvent will adjust the size based on how far the mouse has moved. When mouseReleaseEvent is triggered, the size is "committed" as a command so that it can be reverted using ctrl-z, and resizing is set back to false.

However, I'm having the following issue: If I click the corner, drag the mouse outside of the QGraphicsView, and then right click, move and release events stop coming in. This wouldn't be an issue except that I need the release event in order to finalize the resize so that it can be undone. This can be partially solved by implementing focusOutEvent on the QGraphicsView, so that resizing is finalized if I right click outside of the view; however, this only works if I right click on another widget which accepts focus, and not if I right click in empty space or a widget which doesn't take focus.

I've overridden the general event methods in both the ModuleItem and in QGraphicsView so that they output to the console every time they receive any event. However, when I perform the action described above (click, drag, right click outside the view), no events are received for either the ModuleItem or the QGraphicsView. I cannot figure out any way to reliably detect this situation. Any help would be greatly appreciated.

Summary: Is there a way to reliably detect when the event stream of mousePress -> mouseMove -> mouseRelease is interrupted?