[PyKDE] Top-level windows and ownership

Andreas Gerstlauer andreas at gerstlauer.de
Sun Nov 4 22:44:27 GMT 2001


Hm, yeah, point is that Qt always keeps a reference to all objects. 
The QApplication class keeps a list of all the widgets in the application.
And if the Qt.WDestructiveClose flags is given, Qt will properly dispose
of the window on close(), i.e. it is completely managed by Qt.
I want to tell PyQt that such a window is managed by Qt and not by me. 
Currently, this is implicitly done when a "parent" pointer is given 
to the constructor. There seems to be no other way to do this implicitly
or explicitly if I don't want a parent.

Anyway, for now I implemented the management myself as you suggested. 
The best way seems to be to connect my cleanup/management routine to the 
"destroyed()" signal emitted by Qt when the window is deleted (or 
overload the "closeEvent(e)" method and handle it there)

Andreas


> As far as I understand this isn't possible. Either Python has a reference to 
> your object,
> or a Qt C++ object, or both, but you can't have an object hanging in the air.
>  I'd swallow
> the bitter pill, and do the book-keeping yourself in Python, and connect the 
> closed()
> signal to your window-manager. I think that would be nicer than adding someth
> ing that
> manages C++ ownership that isn't present in Qt itself.
> 




More information about the PyQt mailing list