QRadioButton stylesheet font:bold doesn't work?
-
@Sh1gs
https://stackoverflow.com/questions/37802571/how-to-use-qss-to-set-radio-button-bold-when-checked is reporting the same kind of problem as you. Although the OP seems to say the solutions did not work, I think you should read through and just try them! -
@Sh1gs
some thoughts from my side:- using a
::
in a selector specifies a sub-control of the element, But there is nochecked
subcontrol. You should rather use:checked
. (Even though the official stylesheet docs seem to wrongly mix it up). But i am wondering that it works with the sub-control selector. - Try to unset the font-weight with a
QRadioButton:unchecked
selector
- using a
-
By that thinking, then when the radiobutton is selected, the color shouldn't change, but it does. Changing it to
:
from::
didn't work either. I also tried::unchecked
to set the font weigh to normal and that didn't work :( I don't know what else to try. I've triedfont
,font-weight
,font-style
, and nothing seems to change the font to boldUltimately, I'm fiddling with stylesheets for a work project and would like to find a way to make this happen.
-
@Sh1gs
At this point you should get rid of any:checked
etc. in the selector and just try an unconditional"QRadioButton {" \ "font-weight:bold;" \ "}"
I imagine you will say this does not bold for you, and so we can eliminate anything about the
:checked
qualifier being of any relevance.P.S.
Give a quick desperation try tofont-weight:700;"
instead ofbold
, just in case.... -
Hi
It seems the states checked unchecked do not use any font statements included.
They react fine to color change but any font statements seems to be ignored.
However, its does use its font inherited from QWidget as
targeting that, font is changed.
Also using RadioButton aloneQRadioButton { font: 750 24pt "Arial"; }
So bascially im not sure its possible to make it go bold on checked using
stylesheets alone. -
@mrjj
That is indeed how it was beginning to look. (Though I see some old web posts where users claim bold does work, some do not, various Qt versions.)So you should try
font-style: italic
, and other individualfont-
styles, to verify just which style attribute(s) are affected. Before you check through the Qt source code (it's to do with font in QRadioButton, so it can't be hard to find) and raise a bug report depending on what you find :) -
@Sh1gs
hi
well it does respond to font ,
but not in ::checked ::unchecked
as far as i could see from testing.
The states clearly work as the color was changed
but regardless of font statement used in those
states, i didn't see any effect even same font statement worked
with no state syntax.
So its either a bug, or simply not support for such states. -
@mrjj , @Sh1gs
I did reference https://stackoverflow.com/questions/37802571/how-to-use-qss-to-set-radio-button-bold-when-checked above, which is exactly the situation you are reporting.The "solution" there is only in a comment:
At the end, I use a property to indicate the font bold / normal and setProperty in the slot function. It worked! I wonder the difference between property and checked state
if you can figure what that OP means he did by this and it works for you.
-
@JonB said in QRadioButton stylesheet font:bold doesn't work?:
if you can figure what that OP means he did by this and it works for you.
Probably this:
QRadioButton[checked="true"] { font-weight: bold; }
additionally to that you could try:
connect( radioButton, &QRadioButton::toggled, this, [radioButton]() { radioButton->style()->polish(radioButton); } );
-
@raven-worx
I do think the OP here should try just that.However, the way the OP phrased what he wrote in the stackoverflow comment:
I use a property to indicate the font bold / normal and setProperty in the slot function.
might suggest he had to use a dynamic property (other than
checked
), which he added/removed or switched on/off in thestateChanged
slot handler, to "shadow" the:checked
state and get it to work with font change....