Problem with style sheet fonts
-
I'm relatively new to qt but when i set a style sheet on a label within my stacked widget i set the font colour to black using hex codes, this has worked before but now for some unknown reason when i run my app all fonts unspecified or specified are outputting white and i have no idea why, everything has been set to black as seen in attached images.
-
Do you modify the widget's palette by any chance? Using both QSS and QPalette does not work on a QLabel.
-
OK.
Ah, look at console output: it says that some properties are not recognized. Most likely you have changed the stylesheet and Qt can't parse it now. The really annoying thing about QSS is that when parsing fails, Qt will apply some of the styles, print a warning and ignore the rest of styling info. It's a perfect silent bug, very hard to notice and to fix.
If you are using some source control like git, try bisecting back until you find a working version, then look into changes which happened since then. Also, if you have any compilation or runtime warnings - make sure you fix them.
If you have upgraded Qt recently - try rolling back to the previous version. QSS sometimes breaks.
-
Thanks for the heads up on that runtime error i didnt even notice it, i fixed the bug causing that issue however it didnt have any effect of the text colour
-
-
I have nothing to add, sorry, no further ideas. You need to try and find exactly which change caused the problem.
-
@will_craig maybe it's a hierarchical issue, try to specify the exact object via
#
followed by the objectNamefor example:
QLabel#label_8{ background:"#4CAF50"; font: 40pt "Helvetica" "#000000"; }
-
@sierdzio i just added this highlighted line into the main.cpp file and the output changed all of the text colours that were not attached to one of the stacked widgets pages that had layouts applied. So the ones without layouts changed the pages with remained the same.