Fixing sizes of widgets in QT designer layouts

stefano picture stefano · May 12, 2013 · Viewed 26.8k times · Source

I have a QT form that has literally hundreds of widgets and to make them all fit on the screen at once (as required) I need to make them pretty small. The Form will have fixed (non resizable) size when used. I can resize the widgets to the desired height/width and use the appropriate (small) font size, make their size policy "fixed" etc. However, as soon as I start putting them into layouts, they gow to some, much larger minimum size. This is particularly true for the height of the widgets, but width is sometimes affectged as well.

My problem would be solved if I knew how to do one of the three following things:

  1. Change a layout's default minimum size(s) for widgets.

  2. Force a layout not to alter widgets sizes.

  3. Use Qt designer to nicely align widgets in grid-like formats without using layouts.

I searched extensively Qt designer's docs and SO, to no avail.

Help is greatly appreciated

Answer

Zlatomir picture Zlatomir · May 12, 2013

Use layouts with QWidget::setFixedSize in code (or alternative you can set the fixed size policy for each widget in designer) or you can use QLayout::setSizeConstraint