Qt 布局删除所有控件

    qDebug()<<"%%%%%%%%%%%%%%%%%%%"<<" "<<this->mainLayout->count();
    while(mainLayout->count())
     {
        QWidget *p=this->mainLayout->itemAt(0)->widget();
        p->setParent (NULL);
        this->mainLayout->removeWidget(p);
        delete p;
     }
    qDebug()<<"################"<<" "<<this->mainLayout->count();


你可能感兴趣的:(widget)