How to reduce spacing/padding/margin of the text inside QDoubleSpinBox or QSpinBox to zero?



  • This question is a duplicate of this one on stackoverflow.

    Using Qt 4.8. I would like to set the space between the text of a QSpinBoxes/QDoubleSpinBoxes and the right border of the widget to zero. The left one of the following images is what I got, the right one is what I want:
    QSpinBox, QDoubleSpinBox text padding
    Note that I use setButtonSymbols(QAbstractSpinBox::NoButtons) to remove the up/down arrows.

    The spinboxes are styled using QSS where I can set:

    • The padding of the QSpinBox/QDoubleSpinBox to 0px.
    • The padding, the margin and the border of the QLineEdit inside the spinbox to 0px.
    • I have also created a custom QProxyStyle for the QLineEdit but I'm not able to find any related pixel metric enum that I can use to reduce the space
    • I can also try to mess around with the internal QLineControl class which is not possible without fiddling inside Qt's code base. (I have not tried this yet!)

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.