Yup it does remove the item and you should destroy both.
I often use this function when I need to clear a layout:
void Class
::clearLayout(QLayout *layout
) { if (layout) {
//the key point here is that the layout items are stored inside the layout in a stack
while((item = layout->takeAt(0)) != 0) {
if (item->widget()) {
layout->removeWidget(item->widget());
delete item->widget();
}
delete item;
}
}
}
void Class::clearLayout(QLayout *layout) {
if (layout) {
QLayoutItem *item;
//the key point here is that the layout items are stored inside the layout in a stack
while((item = layout->takeAt(0)) != 0) {
if (item->widget()) {
layout->removeWidget(item->widget());
delete item->widget();
}
delete item;
}
}
}
To copy to clipboard, switch view to plain text mode
The code is easy to read and good looking
Bookmarks