[PyQt] Deleting a PyQt object
mark at qtrac.eu
Thu Nov 22 08:43:00 GMT 2007
On 2007-11-22, Fabian Steiner wrote:
> I'm currently working on a programm which adds a QTableWidget to an
> existing QGridLayout using QGridLayout.addWidget(). When the user pushes
> button btn1, this QTableWidget should disappear and the layout should free
> the space.
> In order to achieve this aim I tried the following:
> del self.legend
> => The QTableWidget is indeed removed from the layout, but still exists in
> the GUI.
> import sip
> => works as expected
> Is this really the right way to do it? Why doesn't the del-approach work?
> Actually no other PyQT objects should hold any other references to
After self.legend was laid out, when the setLayout() call was made on
the widget it appears in, it was automatically reparented to that
widget, so even if you remove it from the layout its parent still has a
reference to it.
Mark Summerfield, Qtrac Ltd., www.qtrac.eu
More information about the PyQt