[PyQt] QGridLayout doesn't remove widgets

Phil Thompson phil at riverbankcomputing.com
Thu Mar 13 10:19:03 GMT 2008

On Wednesday 12 March 2008, Dr. Katja Wegner wrote:
> Hello,
> I have a QWidget with a QVBoxLayout and inside is a QGridLayout to show a
> text and a combo box in each line. If the user pushes the button "change
> grid", the current boxes and labels shall be removed and new boxes and
> labels shall be added. I use removeWidget() but all elements are still
> visible although the layout is updated. I also added a button "delete grid"
> which shall only remove the elements.
> I created a small file for testing which is attached.
> (Python 2.5, Qt 4.3.4, PyQt 4.3.3)
> Thanks a lot,
> Katja

That's the expected behavour. If you actually want to delete the widgets then 
call setParent(None) on them after calling removeWidget().


More information about the PyQt mailing list