Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I allow user resize on elements within the window using Qt designer?

I want to allow a user using my application to be able to drag a boundary between two widgets in my window which will resize the two (i.e. you drag it down and the top one will get bigger while the bottom gets smaller, and vice-versa).

Is there anything in Qt designer that will allow a user to resize an element in the window, within certain constraints?

Thank you

like image 793
Matthew H Thiess Avatar asked Jun 17 '16 16:06

Matthew H Thiess


2 Answers

What you're describing is called a QSplitter widget. In Qt Designer, you can create one by selecting 2 or more widgets, and then clicking the splitter button on the toolbar at the top. It's in the same location as the layout buttons. It will place those widgets inside a QSplitter. You still need to place the splitter widget inside another layout. It will create a handle between them to let you resize the portion that each widget gets.

enter image description here

like image 160
Brendan Abel Avatar answered Nov 05 '22 13:11

Brendan Abel


You're looking for the QDockWidget. It can do all that you described above and more. The user can dock the widget to different sides of the window, changing which widget is on the top or bottom. You can customize the minimum and maximum sizes, as well as default sizes.

like image 1
Daniel Arnett Avatar answered Nov 05 '22 13:11

Daniel Arnett