[Qt-interest] remove buttons from a QVBoxLayout

Rohan McGovern rohan.mcgovern at nokia.com
Mon May 17 09:42:44 CEST 2010


On Monday 17 May 2010, ext Tamas Nagy wrote:
> Hello!
>
> It compiles, but it causes segmentation fault.
>
> for(int i = 0; i < verticalbox->count(); i++)
>     verticalbox->takeAt(i)->widget()->setVisible(false);

That code is wrong... you're removing items from the list while 
iterating over it.  You want something more like:

while (verticalbox->count()) {
    verticalbox->takeFirst()->...
}

-- 
Rohan



More information about the Qt-interest-old mailing list