PDA

View Full Version : QSpinBox not shrinking to content



Lin
9th December 2019, 10:35
I recently updated form Qt 5.7 to Qt 5.13 on Windows using MSVC 2017. The QSpinBoxes now take too much space. This behaviour can be observed for the example qtbase/widgets/widgets/sliders shipped with Qt (just compile and run the example to see that QSpinBox scales ugly compared to previous Qt versions).

It is possible to restore the old behaviour by adding a (completely nonsense) call to setStyleSheet in main.cpp:




int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setStyleSheet("QFoo { }"); // nonsense call to setStyleSheet
Window window;
window.show();
return app.exec();
}



Is there a more elegant way to stimulate the desired behaviour of QSpinBox as before in Qt5.7?

Best regards, Lin

d_stranz
9th December 2019, 16:37
The QSpinBoxes now take too much space.

Your test implies that this is a function of the default style, not the spin box itself. How is it too big? Horizontally, vertically? Both? Try using spacers or stretch factors in your layout to compress things rather than allowing them to fill the available space.

ChristianEhrlicher
9th December 2019, 19:58
I would guess it's a regression in 5.13 - see https://bugreports.qt.io/browse/QTBUG-79806

Lin
10th December 2019, 15:30
I would guess it's a regression in 5.13 - see https://bugreports.qt.io/browse/QTBUG-79806

yes, this seems to be the same regression bug. However, re-setting the minimum of each spinbox in the GUI seems impracticable. Fortunately, calling setStyleSheet (even in an void way) solved the problem for me. As for many applications setStyleSheet is called in a early stage anyway, most programmers won't see the bug.

Lin