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

QFormLayout: widget's vertical sizehints are not respected

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.0.0, 5.12
    • Fix Version/s: 5.14.0 Alpha
    • Component/s: Widgets: Layout
    • Labels:
      None
    • Platform/s:
      All
    • Commits:
      57953174549797d1e87543ff7f70571053caf370 (qt/qtbase/dev)

      Description

      Consider the following code :

      #include <QApplication>
      #include <QFormLayout>
      #include <QPlainTextEdit>
      #include <QLineEdit>
      #include <QDialog>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QDialog w;
      
          QFormLayout lay{&w};
          QLineEdit w1{&w};
          QPlainTextEdit w2{&w};
          w2.setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
          w2.setMinimumHeight(300);
          w2.setMaximumHeight(30000);
      
          lay.addRow("foo", &w1);
          lay.addRow("bar", &w2);
      
          w.show();
      
          return a.exec();
      }
      

      Even though the textedit's maximumHeight is set to 30000, whenever the windows grows, the height of the widget won't ever go past its minimumHeight.

      The same thing with a QGridLayout works as expected :

      #include <QApplication>
      #include <QFormLayout>
      #include <QPlainTextEdit>
      #include <QLineEdit>
      #include <QDialog>
      #include <QLabel>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QDialog w;
      
          QGridLayout lay{&w};
          QLineEdit w1{&w};
          QPlainTextEdit w2{&w};
          w2.setMinimumHeight(300);
          w2.setMaximumHeight(30000);
      
          lay.addWidget(new QLabel("foo"), 0, 0, 1, 1);
          lay.addWidget(&w1, 0, 1, 1, 1);
          lay.addWidget(new QLabel("bar"), 1, 0, 1, 1);
          lay.addWidget(&w2, 1, 1, 1, 1);
      
          w.show();
      
          return a.exec();
      }
      

        Attachments

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

          Activity

            People

            Assignee:
            chehrlic Christian Ehrlicher
            Reporter:
            jcelerier Jean-Michaƫl Celerier
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes