Deleting widgets from PyQt4 QFormWidget

David Boddie david at
Fri Sep 17 00:23:26 CEST 2010

On Wednesday 15 September 2010 18:53, Andrew wrote:

> I'm trying to remove the widgets from the QFormLayout widget from
> PyQt4. According to the documentation I should be able to use the
> command .takeAt(int) which will delete the widget from the layout and
> then return to me the QLayoutWidget.

It will remove the widget from the layout but it won't delete it because
it doesn't own it. The widget will still remain within its parent widget.
You have to either reparent it to another widget, or delete it manually.


> Am I missing a step or is this just broken? I haven't been able to
> find anything else on this issue yet. If it's broke, is there any
> potential workaround?

Try calling deleteLater() on each widget when you take it from the layout.
Does that work?


More information about the Python-list mailing list