Results 1 to 4 of 4

Thread: QSpinBox not shrinking to content

  1. #1
    Join Date
    Dec 2019
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QSpinBox not shrinking to content

    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:

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4. app.setStyleSheet("QFoo { }"); // nonsense call to setStyleSheet
    5. Window window;
    6. window.show();
    7. return app.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

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

    Best regards, Lin

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QSpinBox not shrinking to content

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSpinBox not shrinking to content

    I would guess it's a regression in 5.13 - see https://bugreports.qt.io/browse/QTBUG-79806

  4. #4
    Join Date
    Dec 2019
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSpinBox not shrinking to content

    Quote Originally Posted by ChristianEhrlicher View Post
    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

Similar Threads

  1. Shrinking CircularGauge Area to Displayed Range?
    By droneone in forum Qt Quick
    Replies: 5
    Last Post: 28th August 2016, 22:11
  2. Prevent QMenuBar in QMainWindow from shrinking
    By Radagast in forum Qt Programming
    Replies: 0
    Last Post: 3rd March 2015, 16:02
  3. Expanding/shrinking a widget
    By punkypogo in forum Qt Programming
    Replies: 6
    Last Post: 27th May 2008, 17:50
  4. Shrinking connection dialog
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 23rd April 2008, 20:59
  5. expanding/shrinking issues.
    By Preeteesh in forum Qt Programming
    Replies: 5
    Last Post: 16th June 2007, 22:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.