[PyQt] Fwd: Re: Python has stopped working in PyQt application
Baz Walter
bazwal at ftml.net
Wed Apr 1 18:13:59 BST 2015
> -------- Forwarded Message --------
> Subject: Re:Re: [PyQt] Python has stopped working in PyQt application
> Date: Wed, 1 Apr 2015 14:39:05 +0800 (CST)
> From: redstone-cold <redstone-cold at 163.com>
> To: Baz Walter <bazwal at ftml.net>
>
> Since Qt ensure that objects get deleted in the right order, so is it
> better to let the parent argument not be None, thus causes self to be
> owned by Qt instead of PyQt?
>
There are two parts to every object in PyQt: a Python part and a Qt
part. If you create a widget like this:
self.widget = QtGui.QWidget(self)
there will be two references - one on the Python side, and one on the Qt
side. If all your widgets are connected together with parent/child
links, then it makes it easier for Qt to automatically delete all the Qt
parts (I suppose the children are deleted from the bottom up).
But if most of the deletion is managed from the Python side, it will
sometimes be less reliable, because the correct order of deletion cannot
always be guaranteed (e.g. when the interpreter is closing down).
More information about the PyQt
mailing list