[Qt-interest] Is there any way to dynamically rearrange a dialog's layout?

Ellen Kestrel dragonflykes at gmail.com
Thu May 20 02:49:15 CEST 2010


I have a dialog whose main layout is a QVBoxLayout that contains mostly a
series of identically structured QHBoxLayouts.  The QHBoxLayouts, and the
widgets in them, are all stored in lists of QPointers as members of the
dialog.  I want to make it so that more of these layouts can be added to the
dialog dynamically, so I made slots that added or removed widgets and
layouts to and from these lists of pointers (without actually deleting
anything) and then called an updating function that first removes everything
from the main layout and deletes any layout items that are not in one of the
lists of pointers, and then adds everything that is in a list back into the
main layout.  All of these functions check and recheck for the lists having
the wrong number of items, having null pointers, etc., and print error
messages if anything is wrong.  Yet, in addition to the main layout getting
screwed up and laying out sublayouts on top of other sublayouts, it crashes
at seemingly random times without printing any of my error messages.  What
it does print to the terminal begins thusly:

*** glibc detected *** ./ExecutableName: free(): invalid next size (fast):
0x09778378 ***
======= Backtrace: =========
...

It also constantly prints this message, whether it crashes or not:

QLayout::addChildLayout: layout "" already has a parent

It looks like QLayout::removeItem is not properly removing layouts from
other layouts.  I did not create any of these layouts with parent widgets,
since setting the layouts takes care of that.

Again, at every single point where there could be a null pointer to cause a
crash, *there is error checking*, none of my error messages are ever
printed, and neither is there a standard segfault message.  Is there any way
to do this, or should I just give up?

EK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100519/39aa0bc5/attachment.html 


More information about the Qt-interest-old mailing list