How to Clear all the Widgets in Parent Widgets?

后端 未结 5 1441
臣服心动
臣服心动 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:44

    From Qt docs

    The following code fragment shows a safe way to remove all items from a layout:

    QLayoutItem *child;
    while ((child = layout->takeAt(0)) != 0) {
        ...
        delete child;
    }
    

提交回复
热议问题