[PyQt] Deleting a PyQt object

Fabian Steiner lists at fabis-site.net
Thu Nov 22 07:51:41 GMT 2007


Hello!

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:

[...]
self.ui.gridlayout.removeWidget(self.legend)
del self.legend
[...]

=> The QTableWidget is indeed removed from the layout, but still exists in the 
   GUI.

[...]
self.ui.gridlayout.removeWidget(self.legend)
import sip
sip.delete(self.legend)
[...]

=> 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 
self.legend.

Thanks,
Fabian


More information about the PyQt mailing list