What is the difference between layout default constraint and no constraint?
-
-
I'm reading the documentation of QGridLayout but i still couldn't understand the difference between these two options of layout size constraint:
SetDefaultConstraint
andSetNoConstraint
.Could someone help me understanding it a bit better?
SetNoConstraint
basically does nothing i.e. it does not change the widget's minimum or maximum sizes. If the widget had a min or max size it will keep it. If it didn't then it won't get any either.SetDefaultConstraint
checks if the widget has explicitly set minimum size. If it does then it stays as was set. If it doesn't then widget gets minimum size set from the minimum size calculated by layout.In practice there's no visual difference. The widget won't get smaller than what the layout dictates whether it has minimum size set or not. If you manually set minimum size greater than that calculated by layout it will stay that way no matter which mode you choose -
SetNoConstraint
doesn't change it ever andSetDefaultConstraint
won't change it because it was manually set.The difference is only when you don't explicitly set a minimum size. In that case
SetDefaultConstraint
sets it, whileSetNoConstraint
doesn't, so if you ask widget for itsminimumSize()
it will give you different results with those two modes. -
I'm reading the documentation of QGridLayout but i still couldn't understand the difference between these two options of layout size constraint:
SetDefaultConstraint
andSetNoConstraint
.Could someone help me understanding it a bit better?
@Daniella https://doc.qt.io/qt-5.15/qlayout.html#SizeConstraint-enum
QLayout::SetDefaultConstraint 0 The main widget's minimum size is set to minimumSize(), unless the widget already has a minimum size.QLayout::SetNoConstraint 1 The widget is not constrained.
-
I'm reading the documentation of QGridLayout but i still couldn't understand the difference between these two options of layout size constraint:
SetDefaultConstraint
andSetNoConstraint
.Could someone help me understanding it a bit better?
SetNoConstraint
basically does nothing i.e. it does not change the widget's minimum or maximum sizes. If the widget had a min or max size it will keep it. If it didn't then it won't get any either.SetDefaultConstraint
checks if the widget has explicitly set minimum size. If it does then it stays as was set. If it doesn't then widget gets minimum size set from the minimum size calculated by layout.In practice there's no visual difference. The widget won't get smaller than what the layout dictates whether it has minimum size set or not. If you manually set minimum size greater than that calculated by layout it will stay that way no matter which mode you choose -
SetNoConstraint
doesn't change it ever andSetDefaultConstraint
won't change it because it was manually set.The difference is only when you don't explicitly set a minimum size. In that case
SetDefaultConstraint
sets it, whileSetNoConstraint
doesn't, so if you ask widget for itsminimumSize()
it will give you different results with those two modes. -