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

Nested QWidgets break layout baseline

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.2, 6.3.1
    • Widgets: Layout
    • None
    • macOS

    Description

      When putting a QWidget with a QHBoxLayout and subwidgets into a QHBoxLayout, the baseline for the subwidgets is messed up (macOS).

      E.g.

      #include <QApplication>
      #include <QComboBox>
      #include <QHBoxLayout>
      #include <QLineEdit>
      #include <QPushButton>
      #include <QVBoxLayout>
      
      template<typename T>
      QHBoxLayout *addRow()
      {
          auto widget = new QWidget;
          auto layout = new QHBoxLayout;
          auto control = new T;
          layout->setContentsMargins(0, 0, 0, 0);
          layout->addWidget(control);
          layout->addWidget(new QPushButton("Push"));
          widget->setLayout(layout);
      
          auto row = new QHBoxLayout;
          row->setContentsMargins(0, 0, 0, 0);
          row->addWidget(new QPushButton("Push"));
          row->addWidget(widget);
          row->addWidget(new QPushButton("Push"));
          return row;
      }
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QWidget mainWidget;
          auto vlayout = new QVBoxLayout;
          mainWidget.setLayout(vlayout);
      
          vlayout->addLayout(addRow<QLineEdit>());
          vlayout->addLayout(addRow<QComboBox>());
      
          mainWidget.show();
          return a.exec();
      }
      

      see screenshot

      Attachments

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            con Eike Ziller
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: