QComboBox align text stylesheet?
-
Hi there,
Is it possible to align the text in a QComboBox without setting it to setEditable true? I read someone suggesting stylesheets but I was not able to find any sample code.
I want to align this text in the box to the right side:comboBoxTime->setStyleSheet("align:right;") only gives "Unknown property align"
-
@pauledd
not the QStyle code doesn't consider text alignment.
It determines the alignment itself, just by the QComboBox's layout direction property. But this won't be the result you desire. -
@pauledd said in QComboBox align text stylesheet?:
Thank you, I tried that but it still looks so squashed to the border and it also moves the arrow to the left what makes it looking even more odd,
maybe that has something to do with margins... I will play more around with spacing...
thats why i said the result wont be what you desire.
-
@raven-worx np, thanks anyway
-
QComboBox {background-color:rgb(190,190,190);color:black;padding-left: 10px;padding-right: 30px;border-style: solid;border-width: 0px;}
"padding-left: 10px;"
the padding will shift the combo-box displayed content form the left edge
QComboBox::drop-down {subcontrol-origin: padding; subcontrol-position: top right;width: 40px;border: 0px ;}
"subcontrol-position: top right;"
and the above will position wot text to the right.
Hopefully this helps.