Removing widgets from QGridLayout

后端 未结 2 1143
深忆病人
深忆病人 2020-12-06 01:49

I try to remove widgets from a specified row in a QGridLayout like this:

void delete_grid_row(QGridLayout *layout, int row)
{
    if (!layout ||         


        
2条回答
  •  -上瘾入骨i
    2020-12-06 02:18

    The QGridLayout itself is managing the QLayoutItem's. I believe the moment you call removeWidget the item will be deleted. Thus you have an invalid pointer at that point. Attempting to do anything with it, not just delete, will fail.

    Thus, just don't delete it, you'll be fine.

提交回复
热议问题