1

My main application window is constructed as follows:

  1. A QVBoxLayout;

  2. In its upper cell there is a horizontal QSplitter;

  3. In its lower cell there is a QFrame with QHBoxLayout.

Now, when I add widgets to either QSplitter or QHBoxLayout and there is no room left in them, they both stretch themselves indefinitely (and go offscreen if they can) instead of shrinking the widgets they contain. For the QHBoxLayout part, I tried combining setSizeConstraint(QLayout::SetMaximumSize) with various ways of setting QFrame's width, to no avail. It still stretches uncontrollably. For the QSplitter part, I don't even know what to begin with.

So, what is the magic (and apparently undocumented - I spent 2 hours googling) API call combo for making Qt widget containers shrink their children instead of growing themselves?

sigil
  • 815
  • 8
  • 16
  • From what you say it seems to be an issue of containing the widget in layout. It seems that box layout needs stretch (to consume the space on the left and right for QHBoxLayout) and likewise for QVBoxLayout: http://doc.qt.io/qt-5/qboxlayout.html#addStretch – Alexander V Mar 03 '17 at 15:50
  • Your QVBoxLayout is supposed to arrange all the content in the available space of the window/dialog. But if your content cannot be shrinked enough (having minimum or fixed sizes) it will grow as much as needed to reach the minimum size of the whole content (except if your window is fullscreen or maximized I think). You can either work on your widgets so they are able to reduce more, or use a QFrame/QScrollArea to not expand your window/dialog. – ymoreau Jul 20 '17 at 12:09

0 Answers0