QLayoutItem * QLayout::takeAt ( int index ) [pure virtual]Must be implemented in subclasses to remove the layout item at index from the layout, and return the item. If there is no such item, the function must do nothing and return 0. Items are numbered consecutively from 0. If an item is removed, other items will be renumbered.
The following code fragment shows a safe way to remove all items from a layout:
C++ (Qt)
QLayoutItem *child;
while ((child = layout->takeAt(0)) != 0) {
...
delete child;
}
Удалять ещё и child->widget()