Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-17730

Separate horizontal and vertical size constraints for QLayout

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Fixed
    • Icon: Not Evaluated Not Evaluated
    • None
    • 4.7.1
    • Widgets: Layout
    • None
    • 39b98747a (dev), 96c1a38b1 (6.9), 2b60d2fad (tqtc/lts-6.8), 5b33c4e84 (dev), 0076b9345 (dev), 48f65d8fa (dev), 977b6daa9 (dev), 663464036 (6.9), bb357e3ea (tqtc/lts-6.8), 72676f45f (6.9), e887eef1a (tqtc/lts-6.8)

      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());
      }
      

        For Gerrit Dashboard: QTBUG-17730
        # Subject Branch Project Status CR V

            tmartsum Thorbjørn Lund Martsum
            hendrik Hendrik Fuß
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: