[Qt-interest] Problem with adding/removing/adding elements in a QVBoxLayout

Juan Pablo Crossley crossleyjuan at gmail.com
Tue May 19 18:33:07 CEST 2009


Finally!

I solved this, the problem was with the memory deletion of the child
widget,

    QVBoxLayout* box = (QVBoxLayout*)layout();

    QLayoutItem* item;
    while ((item = box->takeAt(0)) != 0) {
        box->removeWidget(item->widget());
        delete item->widget();    <<<---- very important step!!!!
    }

After removing the widget using the "removeWidget" you must delete the
item, so I combined the removeWidget with the delete and it did the
trick.

I Hope this could save time to somebody else.


-- 
Cross
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090519/2a4478fb/attachment.html 


More information about the Qt-interest-old mailing list