[PyQt] Fwd: Re: Python has stopped working in PyQt application

redstone-cold redstone-cold at 163.com
Thu Apr 2 06:06:23 BST 2015



For 
self.widget = QtGui.QWidget(self)
Which is responsible for destroy self.widget when application exist ?






在2015年04月02 01时13分, "Baz Walter"<bazwal at ftml.net>写道:

> -------- 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).
_______________________________________________
PyQt mailing list    PyQt at riverbankcomputing.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150402/43a38901/attachment.html>


More information about the PyQt mailing list