Qt布局内控件的销毁

destroyMainLayoutWidget(QLayout* layout){
    QLayoutItem *child;
    int num = layout->count();
    if(num != 0){
        while (!layout->isEmpty())
        {
            child = layout->takeAt(0);
            if(child->widget())
            {
                child->widget()->setParent(nullptr);
            }else if(child->layout()){
                destroyMainLayoutWidget(child->layout());
            }
            delete child;
        }
    }

}

  

posted @ 2021-02-01 13:55  NAVYSUMMER  阅读(541)  评论(0)    收藏  举报
交流群 编程书籍