Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Why do my nested layouts overlap?
This is the result of the code below:
bars_and_scrollbars_layout_ptr = new QGridLayout(this) ; bars_and_scrollbars_layout_ptr->setSpacing(6) ; bars_and_scrollbars_layout_ptr->addWidget(ui.qcustomplot_ptr, 0, 0, 3, 3) ; ..... control_buttons_layout_ptr = new QGridLayout(this) ; control_buttons_layout_ptr->setSpacing(6) ; .... main_layout_ptr = new QVBoxLayout(this) ; main_layout_ptr->setSpacing(6) ; main_layout_ptr->insertLayout(0, bars_and_scrollbars_layout_ptr) ; main_layout_ptr->insertLayout(1, control_buttons_layout_ptr) ; ..... setLayout(main_layout_ptr) ;
What I want to see is the layout that hosts the buttons (by the way only one is visible for some reason) below the chart.
What a I forgetting?
Thanks in advance!
Can't you use the designer for it? It even looks like you're already using a designer-created ui:
[Edit aha_1980: Fixed typo]
I prefer not using the designer.
Any idea what's going on here?
You are trying to assign every single one of your layouts to the widget. Using
thisin the constructor makes it equivalent to
main_layout_ptr = new QGridLayout() ; setLayout(main_layout_ptr)
It's likely not what you want.
I'm sorry I don't understand: What is it that you suggest I do to get vertical container embed 2 grid containers?
Nope he suggests you do not assign parent in the constructor of the sub-layouts. ( as i read it ;)
bars_and_scrollbars_layout_ptr = new QGridLayout(
control_buttons_layout_ptr = new QGridLayout(
I am not sure though why this caused the issue above. I solved it by indeed removing "this" and indicating the column span for the buttons.
But why does indicating parenthood cause this? I find this part to be much harder than in Python based GUI, for example...
somelayout = new QGridLayout() ;
Which is super when its standalone layout but as you have seen give strange side effects
if later assigned as sub-layout.
I use mostly Designer as its so quick to design even complex layouts so I didn't even spot it when looking
at your code.
Thank you all for the time and the effort !
Please mark it as solved using the Topic button