QTabwidget - a problem with layouts
-
Hi, Qts!
Please suggest a way out
I have a task to make an app with two different graphs.I've created a QMainWindow app, put a Horizontal QHBoxLayout and inside it QTabWidget.
I has made two pages, each of every future graph.
I set up the tabwidget Layout property as vertical
I put three QVBoxLayouts on the fist page and it looked good.But when I tried to make layouts on the second page I could not do it. It means I cannot do my second graph on the second tab.
I also have found out that the pages of the QTabWidget have no Layout properties and therefore layouts on them don't stretch when the app changes its size.
Can you suggest how I can do my task? Maybe I should you some other widgets? The same thing happens with QStackedWidget
Just ib case I send my test screenshot.
-
C Christian Ehrlicher moved this topic from C++ Gurus on
-
Hi, Qts!
Please suggest a way out
I have a task to make an app with two different graphs.I've created a QMainWindow app, put a Horizontal QHBoxLayout and inside it QTabWidget.
I has made two pages, each of every future graph.
I set up the tabwidget Layout property as vertical
I put three QVBoxLayouts on the fist page and it looked good.But when I tried to make layouts on the second page I could not do it. It means I cannot do my second graph on the second tab.
I also have found out that the pages of the QTabWidget have no Layout properties and therefore layouts on them don't stretch when the app changes its size.
Can you suggest how I can do my task? Maybe I should you some other widgets? The same thing happens with QStackedWidget
Just ib case I send my test screenshot.
@qAlexKo
Don't ask me how it works with layouts in Designer, it's a dark art! But try doing it this way:- Delete the layout you currently show on
tab_2
. - Drag any widget onto it, say a Push button. You need to do this.
- Now right-click on the Tab 2 in the designer (middle pane).
- Bottom of context menu, Lay out > sub-menu, pick Lay Out Horizontally/Vertically.
- You may now delete the push button you created earlier if you wish. Without it there you would not be able to set the layout, but once you have done so the layout stays even if no widgets.
You end up with the Object Explorer at right showing like:
Note that mytab_2
does not have the "red no-entry sign" yours does. That indicates a missing layout, and things won't work while in that state.As I said, do not ask me about setting the layout this way versus you dragging a layout object onto it, because I don't know! I just know this way works. I don't think I have ever picked a layout object. I would go back and do your first
tab
the same way too. - Delete the layout you currently show on
-
@qAlexKo
Don't ask me how it works with layouts in Designer, it's a dark art! But try doing it this way:- Delete the layout you currently show on
tab_2
. - Drag any widget onto it, say a Push button. You need to do this.
- Now right-click on the Tab 2 in the designer (middle pane).
- Bottom of context menu, Lay out > sub-menu, pick Lay Out Horizontally/Vertically.
- You may now delete the push button you created earlier if you wish. Without it there you would not be able to set the layout, but once you have done so the layout stays even if no widgets.
You end up with the Object Explorer at right showing like:
Note that mytab_2
does not have the "red no-entry sign" yours does. That indicates a missing layout, and things won't work while in that state.As I said, do not ask me about setting the layout this way versus you dragging a layout object onto it, because I don't know! I just know this way works. I don't think I have ever picked a layout object. I would go back and do your first
tab
the same way too.@JonB Thanks for explanation, I also have found something in the internet here:
https://www.youtube.com/watch?v=8JYEdXDhrTYIt is without voice, and you will need to grasp why it doesn't work ;-) -- because it does work and make the process very easy.
Attention: when you follow the clip and put a new layer on the locked second tab you must(!) click then on the second tab page and only after that press the right button and call the Layer menu. In the menu you must choose "Lay out in a Grid". ;-))) It was fun, in short. ;)
- Delete the layout you currently show on