Details
-
Suggestion
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
4.7.1
-
None
Description
Problem
QLayout's layoutSizeConstraint property only allows for the same constraint type for both horizontal and vertical dimensions.
Suggested solution
If one could specify separate constraints, one could easily create a window that is resizable only in horizontal direction. For example:
QLayout *l = new QVBoxLayout(Form);
l->setSizeConstraint(QLayout::SetFixedSize, QLayout::SetDefaultConstraint);
This is consistent with QWidget's sizePolicy, which also has a horizontal and vertical components.
Such a solution would be especially useful for shape-changing dialogs, where e.g. height is fixed, but changes depending on the state of the dialog.
Workarounds
Currently, it is very difficult to work around this issue. Using maximum and minimum sizes defeats the purpose of using automatic layouts and requires extra effort to account for dynamic changes to the layout's content.
Constructs like the following do not always work, depending on the complexity of the layout:
void MyDialog::adjustHeight() { resize(width(), sizeHint().height()); }