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

[REG 5.12.5 -> 5.13.2] QDoubleSpinBox sizeHint() way too wide

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.15.0 Alpha
    • 5.13.2
    • None
    • Windows 10 on 4K monitor
    • Windows
    • 2614347ab8aa0ec0b1ea8f383ae795cfdb6ae2ac (qt/qtbase/5.15)

    Description

      The sizeHint() for a QDoubleSpinBox is way too wide after construction of an instance.

      Once an instance of the QDoubleSpinBox is shown and the 'setMinimum()' (or 'setRange()') method is called, the correct width is used. This is demonstrated by the code below.

      The first spinbox is too wide for the range ([0..99]) and precision (2 decimals). The second spinbox is the same, but its minimum value is set again (to the same value) after it is shown. This causes the second spinbox to have the correct width.

       

      code to reproduce this bug:

      #include <QtWidgets>
      
      int main(int argc, char **argv)
      {
          QApplication app(argc,argv);
          // spin boxes with range: [0..99] and 2 decimal places
          QDoubleSpinBox *spinbox1 = new QDoubleSpinBox();
          QDoubleSpinBox *spinbox2 = new QDoubleSpinBox();
          QHBoxLayout *testlayout = new QHBoxLayout();
          testlayout->addWidget(spinbox1);
          testlayout->addWidget(spinbox2);
          testlayout->addStretch();
          QWidget testwidget;
          testwidget.setLayout(testlayout);
          testwidget.show();
          spinbox2->setMinimum(spinbox2->minimum()); // <- ensures correct size hint
      
          return app.exec();
      }
      

       

      Attachments

        Issue Links

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

          Activity

            People

              chehrlic Christian Ehrlicher
              ev E Visser
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes