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

QGridLayout does not allocate sufficient space to all widgets if it has one widget with setMaximumWidth property.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.8.6, 5.2.0
    • 4.7.4, 4.8.0, 5.0.0 Beta 1
    • Widgets: Layout
    • None
    • Windows7
    • c3958b592a1d46eb1b536bd09cce1aa919d02635 b855e578044e49b588b32085968c63a910b9daae

    Description

      If we have one widget in grid layout having maximum width fixed, other widgets in the layout does not get sufficient space.
      Following example demonstrate this.

      #include <QtGui>
      
      
      int main(int argc, char** argv)
      {
          QApplication app(argc, argv);
          QWidget widget;
          QGridLayout grid(&widget);
          QHBoxLayout hbox;
          hbox.addWidget(new QRadioButton("Button one", &widget));
          hbox.addWidget(new QRadioButton("Button two", &widget));
          hbox.addWidget(new QRadioButton("Button three", &widget));
      
          grid.addLayout(&hbox, 0, 0,1,6);// with this combo box is not fully shown
          //grid.addLayout(&hbox, 0, 0); // with this there is huge space between line edit and labels
      
          QLineEdit* edit(new QLineEdit(&widget));
          edit->setMaximumWidth(40);
          grid.addWidget(edit, 1, 0);
          grid.addWidget(new QLabel("A", &widget), 1, 1);
          grid.addWidget(new QLabel("B", &widget), 1, 2);
          grid.addWidget(new QLabel("C", &widget), 1, 3);
          grid.addWidget(new QLabel("D", &widget), 1, 4);
          grid.addWidget(new QLabel("E", &widget), 1, 5);
      
          widget.show();
          return app.exec();
      }
      

      Using gridlayout25801:

      • Run example
      • Run example with option -m: Note widgets are squeezed.

      Attachments

        Issue Links

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

          Activity

            People

              smd Jan Arve
              irfan.omair@gmail.com irfan B omair
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes