[PyQt] cleaning up after removing items from layout

Lee Harr missive at hotmail.com
Sat Nov 7 23:59:13 GMT 2009


I have a fairly complex layout created with Qt Designer.

In one area, there is a QVBoxLayout which I fill up with
items at runtime. It works fine, resizes nicely, looks good.

The problem is that at some point I want to remove all of
those items and fill it up again with all new items.

The new items that get put in work fine also, and as long
as the window never gets resized it looks good. But as
soon as the window size changes, I can see that the old
items are still there somehow.


The code I'm using to clear out the layout looks something
like this:

while layout.count():
    item = layout.itemAt(0)
    layout.removeItem(item)


The items are actually QHBoxLayouts with several things
inside of them. I can't call item.destroy() because they
don't have a destroy method.

I tried manually creating a destroy method that goes
through and destroys everything in the item, but that
is not doing the trick either.


How can I make sure that the items get completely
destroyed, all the way down to everything that is
contained?

 		 	   		  
_________________________________________________________________
Windows Live: Keep your friends up to date with what you do online.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010


More information about the PyQt mailing list