Home > OS >  Does Qt's QLayout by default squezze/overlap all widgets on layout area?
Does Qt's QLayout by default squezze/overlap all widgets on layout area?

Time:11-03

If you implement for example a QHBoxLayout with a fixed width (determined by a parent layout) and add more widgets (with a given minimum size) than fit into the fixed layout area, the widgets are getting smaller than the minSize and at a certain point even overlap. Is this (ignoring minimumSize, spacing) the default implementation?
If yes, how would you achieve to keep the minimumSize and "push" other widgets out of the layout area or only partially draw the widgets (clip to layout area)?

CodePudding user response:

I came across what seems to be the c source code for the layout kernel. Layouts are calculated within the qLayoutengine. For GridLayouts, BoxLayouts that is done via internal qGeomCalc method. There it is stated: "It portions out available space to the chain's [chain: struct of layoutItems and its geometry] children".
So minimumSize will get ignored in order to "pack" all items into the given space.

  •  Tags:  
  • qt
  • Related