I need help on adding layout to layout
I have an main grid which is a QBoxLayout. When I create a layout on designer, using mainGrid->addLayout(layout) doesn't work, but if I create a layout programmatically, it works.
Now I have a problem, I have created a layout called smallLayout, adding some widgets to it programmatically then using mainGrid->addLayout(smallLayout) to add it to the main grid, everything's fine and dandy. Now I have to move that layout into another grid when users do something in runtime. I used subGrid->addLayout(smallLayout) and it doesn't work, I think it's because I already add widgets to it or put it inside another layout already.
I don't really understand why that happened? With widgets it's fine when you reassign layout for it but with layout it doesn't work.
Also do I have to delete all child layout inside mainGrid before closing the program to avoid memory leak?
In that case, wouldn't having a widget to move around be simpler ?
No you don't, Qt's parent/child relationship will handle that for you.
@SGaist I just don't know why addLayout doesn't work and since there is no discussion about it, I just thought I did something wrong.
But everything's good now that I set every sub layout to their own groupbox, so the main layout just need to add the groupboxes. Thanks.
You're welcome !
Handling a layout and handling a widget is two different things. If you want to see the gory details, I encourage you to take a look at the layout classes source code.
Since you have a "workaround", please mark the thread as solved using the "Topic Tool" button so other forum users may know a solution has been found :)