从布局中删除一个部件:
QLayoutItem *item = ui.horizontalLayout->layout()->takeAt(0);
if (item != 0)
{
QWidget * pWidget = item->widget();
ui.horizontalLayout->layout()->removeWidget(pWidget);
delete pWidget;
pWidget = NULL;
}
removeWidget 并不会真正释放部件内存,只是单纯的将部件从不居中删除。
从tabWidget中删除tab
for (int i = 0; i < vTabs.size(); i++)
{
int icount = ui.tabWidget->count();
QWidget * pWidget = ui.tabWidget->widget(0);
if (0 != pWidget)
{
delete pWidget;
pWidget = NULL;
}
//ui.tabWidget->removeTab(0);
}