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

QGridLayout does not align comboboxes baselines correctly in Mac style.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • Some future release
    • 4.5.3
    • Widgets: Layout
    • None
    • macOS

    Description

      The following shows the issue, notice how the __ __ do not align perfectly.

      #include <QApplication>
      #include <QFont>
      #include <QGridLayout>
      #include <QLabel>
      #include <QLatin1String>
      #include <QLineEdit>
      #include <QComboBox>
      
      int main(int argc, char ** argv)
      {
          QApplication app(argc,argv);
          QWidget *     window = new QWidget();
          QGridLayout * grid   = new QGridLayout(window);
          grid->setHorizontalSpacing(0);
          QLabel *fileLabel = new QLabel ("bug part one ___");
          QStringList list ;
          list << "___ value 1" << "___ value 2" << "___ value 3" << "___ value 4";
          QComboBox *fileComboBox;
          fileComboBox = new QComboBox;
          fileComboBox->addItems(list);
          QGridLayout *mainLayout = new QGridLayout;
          grid->addWidget(fileLabel, 0, 0,1,1,Qt::AlignLeft | Qt::AlignVCenter);
          grid->addWidget(fileComboBox, 0, 1,1,1,Qt::AlignRight | Qt::AlignVCenter);
          window->show();
      
          return app.exec();
      }
      

      The following patch seems to fix the issue:

      diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
      index ee106eb..273a7d5 100644
      --- a/src/gui/styles/qmacstyle_mac.mm
      +++ b/src/gui/styles/qmacstyle_mac.mm
      @@ -4601,7 +4601,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
               } else {
                   rect = opt->rect;
                   if (controlSize == QAquaSizeLarge) {
      -                rect.adjust(+3, +2, -3, -4);
      +                rect.adjust(+3, +5, -3, -4);
                   } else if (controlSize == QAquaSizeSmall) {
                       setLayoutItemMargins(+2, +1, -3, -4, &rect, opt->direction);
                   } else {
      

      Attachments

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

        Activity

          People

            smd Jan Arve
            dettman Dean Dettman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes