Customize QDoubleSpinBox text align with CSS
-
Hello,
I try to customize a double spin box.
In Qt designer I have the following lines in the style sheet editor.
QDoubleSpinBox {font-size: 20px; text-align: right}
QPushButton{text-align: right}

text-align: right has no effect in the spin box
How can I change the alignment in the spin box?
-
Hello,
I try to customize a double spin box.
In Qt designer I have the following lines in the style sheet editor.
QDoubleSpinBox {font-size: 20px; text-align: right}
QPushButton{text-align: right}

text-align: right has no effect in the spin box
How can I change the alignment in the spin box?
@Bert59
AQSpinBoxhas an internalQLineEditchild for the number text. I won't lie to you, I have had trouble accessing that fully, and reported a bug, but it never got addressed. But I did successfully change the text alignment (mine was from code, not stylesheet, for this). That is what you will need to set thetext-alignon. Try it from stylesheet rule (QDoubleSpinBox.QLineEditor whatever the docs say the syntax is a for a child, I can't remember?), though that may be what I found did not work right. Or to verify my claim set the stylesheet directly from code onspinBox->lineEdit()to check it works. Note that method isprotected, to access you either need to sub-class or usespinBox->findChild<QLineEdit *>().