Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT/QT-Designer Question: auto-resizing widget

Tags:

qt

Using QT-Designer, I put a container widget on my window. I'd like it to snap to the edges of the window and cover the entire client area. The window is resizeable.

Do I have to subscribe to resize events and manually change the size of the child widget? or is there some mechanism I can use that does that automatically?

like image 549
JasonGenX Avatar asked Jan 28 '11 15:01

JasonGenX


1 Answers

Just select the main window widget in the form editor and tell it to lay out its children horizontally (Ctrl-1) or vertically (Ctrl-2). They're under the Form menu.

(If you're using Qt Creator use Ctrl-1, Ctrl-2 or under the menu in Tools -> Form Editor.)

If you change your mind later you can break the layout and rearrange things.

The "expand to fill the available space" is the general rule in Qt (as per most other toolkits.) It's probably worth reading up on QLayout and layout management in general.

like image 126
Mikesname Avatar answered Jan 01 '23 08:01

Mikesname