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

QFormLayout does not calculate width of rows without label properly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.13.0 Alpha 1
    • 5.8.0
    • Widgets: Layout
    • None
    • All
    • 8c38b08343b226883ef368d31a085b0a620f7995

      Take a look at the code below:

       

      #include <QtWidgets>
      
      int main(int argc, char** argv)
      {
        QApplication app(argc, argv);
        QWidget w;
        QFormLayout* ll = new QFormLayout(&w);
        ll->setWidget(0, QFormLayout::LabelRole, new QLabel("123245689"));
        ll->setWidget(0, QFormLayout::FieldRole, new QSpinBox);
        ll->setWidget(1, QFormLayout::FieldRole, new QCheckBox("some other text"));
        w.show();
        app.exec();
      }
      

       

      Here is how it looks:

      A simple change in code

      ll->setWidget(0, QFormLayout::LabelRole, new QLabel("123245689"));
      ll->setWidget(0, QFormLayout::FieldRole, new QSpinBox);
      ll->setWidget(1, QFormLayout::LabelRole, new QLabel("123245689"));
      ll->setWidget(1, QFormLayout::FieldRole, new QCheckBox("some other text"));

      will fix it:

        1. image-2017-05-12-22-24-14-336.png
          3 kB
          Michał Walenciak
        2. image-2017-05-12-22-25-53-581.png
          4 kB
          Michał Walenciak
        For Gerrit Dashboard: QTBUG-60800
        # Subject Branch Project Status CR V

            chehrlic Christian Ehrlicher
            kicer Michał Walenciak
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes