Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt drag resize widget?

Tags:

Suppose I have two Qt widgets in a vertical layout inside a parent widget.

Is there someway to add a control "border" between them such that when you click and drag the border area in between the two widegets you can change the relative area of the parent they take?

That is if you drag it up then the bottom widget gets resized bigger and the top widget gets resized smaller.

like image 934
Andrew Tomazos Avatar asked Jan 29 '13 14:01

Andrew Tomazos


1 Answers

All you need is QSplitter.

If you prefer creating widgets in code, look the docs from the link above.

If you like visual layout in QtDesigner/QtCreator, you may download my recent little project and open in in QtCreator. In mainwindow.ui you'll find a lot of QSplitters! You can create them using context menu: select two widgets -> right click -> Lay out -> Lay out vertically in a splitter.

In short, replace your vertical layout with a single QSplitter and add your two widgets to it as children.

like image 169
NIA Avatar answered Sep 19 '22 00:09

NIA