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

Qt4.3.3/Mac: Top margin in QDialog too large in nested layouts with QGroupBox

    XMLWordPrintable

Details

    Description

      Trolltech Qt Quarterly Issue 23 mentions that Layout spacing is now more "Mac Like".

      This is true for QGroupBoxes placed direcly in a QGridLayout, but QGroupBoxes placed in nested layouts still have too much spacing.

      The difference between the two methods can be seen in the following demo code:

      #include <QtGUI>

      QGroupBox *createRadio(){
      QGroupBox *groupBox = new QGroupBox(("Radio"));
      QVBoxLayout *glr = new QVBoxLayout(groupBox);
      glr->addWidget(new QRadioButton("Button 1"));
      glr->addWidget(new QRadioButton("Button 2"));
      glr->addWidget(new QRadioButton("Button 3"));

      return groupBox;

      }

      QGroupBox *createCheck(){
      QGroupBox *groupBox1 = new QGroupBox(("Check"));
      QVBoxLayout *glc = new QVBoxLayout(groupBox1);
      glc->addWidget(new QCheckBox("Button 1"));
      glc->addWidget(new QCheckBox("Button 2"));
      glc->addWidget(new QCheckBox("Button 3"));
      glc->addWidget(new QPushButton("Push"));

      return groupBox1;
      }

      class Window : public QWidget{
      public:
      Window(QWidget *parent = 0);
      };

      class cDialog : public QDialog {
      public:
      cDialog(void);
      };

      Window::Window(QWidget *parent)
      : QWidget(parent)
      {
      QGridLayout *grid = new QGridLayout();
      grid->addWidget(createRadio(), 0, 0);
      grid->addWidget(createCheck(), 0, 1);

      setLayout(grid);

      setWindowTitle(tr("Grid Layout Group Boxes Sample"));
      }

      cDialog::cDialog(void)
      {
      QVBoxLayout *vbl = new QVBoxLayout(this);
      QHBoxLayout *hbl = new QHBoxLayout;

      vbl->addLayout(hbl);

      hbl->addWidget(createRadio());
      hbl->addWidget(createCheck());

      setWindowTitle(tr("Nested Layouts Group Boxes Sample"));
      }

      int main(int argc, char *argv[]){
      QApplication myapp(argc, argv);

      Window window;
      window.show();

      cDialog d;
      d.show();

      myapp.exec();
      return 0;
      }

      #include "main.moc"

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            dettman Dean Dettman (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes