How to Clear all the Widgets in Parent Widgets?

后端 未结 5 1432
臣服心动
臣服心动 2020-12-17 09:40

I am using the constructor QWidget(QWidget *parent). This parent widget contains a lot of child widgets. I need to clear all the child widgets from the parent a

5条回答
  •  不思量自难忘°
    2020-12-17 09:48

    You can use the following in your parent widget class:

    QList widgets = findChildren();
    foreach(QWidget * widget, widgets)
    {
        delete widget;
    }
    

提交回复
热议问题