10

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

stefano
  • 769
  • 2
  • 10
  • 24

1 Answers1

5

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

Zlatomir
  • 6,964
  • 3
  • 26
  • 32
  • 4
    I'd tried to set the widgets' size policy to "fixed" (see question). But it does not work. As soon as I apply a layout in Qt Designer the widgets grow. However, I later found out that setting also the widget's minimimum and maximum sizes (in addition to their size policy) seems to work. Thanks for prompting me to try harder ;-) – stefano May 12 '13 at 17:49
  • i didn't use that much fixed size widgets, but if i remember correctly they are not supposed to grow (size it's set at the size parameter or the sizehint for QLayout setter) so fixed size should be enough, but if the layout they are in can grow the space between widgets grows, so are you sure that you didn't observe that behavior (try with widgets that have observable margins) or you have some custom widgets? Anyway see if you can replicate the issue (make a test app so you don't mess-up your app) and maybe post it here so we can take a look. Anyway, i'm glad my comment helped a little. – Zlatomir May 12 '13 at 18:14
  • @stefano It was sufficient for me to set minimumSize and maximum size within qtcreator for the appropriate QWidget (which can be a button or whatever). Setting constraints was not necessary – Anonymous May 30 '17 at 08:55