Python Forum

Full Version: PyQT5 - connect to mouseMoveEvent
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have class which inherits from QGraphicsRectItem which is being displayed in a graphics scene/view. It's just a rectangle that can be moved by dragging and resized, currently one of the functions it overrides is from QGraphicsRectItem is 'mouseMoveEvent'. I want to be able to connect other widgets to this event so as it's moved I can update the widgets.

I've tried looking through the class to see if there were in-built signals I could connect to, like buttons 'clicked' signal, but I've had no luck so far.

Thanks in advance,
Kaine

EDIT:
So I attempted using signals for the QGraphicsRectItem but worked out that a class must derive from QObject to use signals. So far what I've done is subclassed my QGraphicsScene and have added signals to that. That way I can emit the signal in the QGraphicsRectItem by doing self.scene().mySignal.emit().

Please let me know if this is bad practice/there is a better way of accomplishing this.
Thanks :)