[PyQt] How do I intercept widget destruction?

Matt Newell newellm at blur.com
Wed Oct 22 17:49:51 BST 2008


On Wednesday 22 October 2008 09:31:18 Jeremy Sanders wrote:
> Hi - this may be an FAQ, but I haven't seen it.
>
> Is it possible to receive notification just before a QWidget is destroyed
> in Python by subclassing? I'd like to call some cleanup routines for a
> custom widget when it is removed from the screen.
>
> Thanks
>
> Jeremy

If you subclass you can override QWidget.closeEvent, QWidget.hideEvent, or the 
destructor.

If you want to moniter it without subclassing, you can use an event filter or 
connect to the QObject.destroyed signal.

Matt


More information about the PyQt mailing list