[Interest] Taking back a widget from a QBoxLayout?

Roland Hughes roland at logikalsolutions.com
Tue Mar 19 01:12:09 CET 2019

Not a troll but willing to take a bit of a stab.

If one is removing a widget from a layout it's generally to reparent it. 
You needed to copy the line above the note.


Removes the widget /widget/ from the layout. After this call, it is the 
caller's responsibility to give the widget a reasonable geometry or to 
put the widget back into a layout.


A widget removed from a layout tends to not have a reliable geometry. If 
one is going to delete the widget a better question would be, why bother 
removing it. You have the pointer already so just do


On 2/23/19 4:00 AM, interest-request at qt-project.org wrote:
> So addItem parents it as it's own, then removeItem leaves it. No wonder it was crashing. This might be a bug? I don't know why removing it would keep the parent (the layout) then your subsequent call to delete deleted the widget and it's layout, so the parent was left dangling.  I would have expected that the parent be nulled out, rather than keep it referencing the layout it had just been added to and removed from. Perhaps a Troll can comment?

Roland Hughes, President
Logikal Solutions
(630)-205-1593  (cell)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190318/90f3a9e2/attachment.html>

More information about the Interest mailing list