Qt - remove all widgets from layout?

前端 未结 12 659
野性不改
野性不改 2020-12-01 01:33

This doesn\'t seem easy. Basically, I add QPushButtons through a function to a layout, and when the function executes, I want to clear the layout first (removi

12条回答
  •  醉话见心
    2020-12-01 02:30

    only works for my buttonlist, if the widgets themeselves are deleted, too. otherwise the old buttons are still visible:

    QLayoutItem* child;
    while ((child = pclLayout->takeAt(0)) != 0)
    {
        if (child->widget() != NULL)
        {
            delete (child->widget());
        }
        delete child;
    }
    

提交回复
热议问题