Center align text in radio button
-
Can we center align text in QRadioButton?
-
Gerolf, but how do i center align the text.
-
How do define pRadio and in which file?
-
pRadio is your QRadioButton object.
-
QRadioButton {text-align: center;} didn't work for me. I am not sure if QT picks text-align for QRadioButton.
I was able to get the indicator center align, however then the text is left align to the indicator, so it is on the center but not properly align.
All I want is to center align the text as it gets for indicator.
-
not sure if text-align will be recognized.
Other approaches I'd try:-
You can create your own complex control as stated above
-
You can play with this: "http://developer.qt.nokia.com/faq/answer/how_can_i_draw_custom_subcontrols_for_a_complex_control":http://developer.qt.nokia.com/faq/answer/how_can_i_draw_custom_subcontrols_for_a_complex_control
-
can play with values below and get close to what you want ...
@
QRadioButton {
spacing: 5px;
}
QRadioButton::indicator {
width: 50px;
height: 13px;
}
@ -
You can try to edit/extend gui module to support this ...
see qcommonstyle.cpp and qstylesheetstyle.cpp, SE_RadioButtonIndicator and SE_RadioButtonLableSpacing are of interest to you
-
-
[quote author="NDev" date="1297325032"]Is there a way I can find the size/width of the QRadiobutton text and adjust the spacing accordingly? [/quote]
yes: text() is available. Also since a QRadioButton extends a QWidget: font(), fontinfo(), fontmetrics() are all available ..