1 QLayout* pLayout = (QLayout*)ui->frame->layout(); 2 while(child = pLayout->takeAt(0)) 3 { 4 QWidget* pWidget = child->widget(); 5 pWidget->deleteLater(); 6 delete child; 7 }