In my app I have a treeview at the top with some buttons above it related to the treeview. Below this I have a table view, again with some buttons related to it. I have a QVBoxLayout top and bottom.
Please see the screen show.
What I'd like to do is be able to adjust the size of the top and bottom in the way that a QPlitter allows you to do. But ... a QSplitter only accepts widgets, not layouts.
I'd like to be able to drag where the red line is in the screen shot.
I'm creating the layout in C++ not in the designer.
Is there a way to do this?
Detailed Description. A splitter lets the user control the size of child widgets by dragging the boundary between them. Any number of widgets may be controlled by a single splitter. The typical use of a QSplitter is to create several widgets and add them using insertWidget() or addWidget().
QVBoxLayout organizes your widgets vertically in a window. Instead of organizing all the widgets yourself (specifying the geographic location), you can let PyQt take care of it. Every new widget you add with . addWidget() , is added vertically. Basically you get a vertical list of your widgets.
Wrap your widgets inside another widget, like so:
Splitter
├──Top Widget
│ └──Layout 1
│ ├──Button 1
│ ├──Button 2
│ └──Text Area 1
└──Bottom Widget
└──Layout 2
├──Button 3
├──Button 4
└──Text Area 2
Example:
QWidget *topWidget = new QWidget;
topWidget->setLayout(layout1);
...
splitter->addWidget(topWidget);
splitter->addWidget(bottomWidget);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With