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

Separate horizontal and vertical size constraints for QLayout

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.7.1
    • Widgets: Layout
    • 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());
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vfm Thierry Bastian (closed Nokia identity) (Inactive)
            hendrik Hendrik Fuß
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes