How do I change the colour of the text of a CheckBox?
-
wrote on 13 Nov 2013, 22:26 last edited by
Sorry for annoying again, but I've tried all things I have found, and neither of them seemed to work.
I need to match some colours to some checkboxes. I have read that stylesheets don't work here, HTML formatting neither, and the only other solution was modifying the palette. I have tried to do it inQtDesigner, and it worked, but I can't find a way to do it dynamically.
My code (doesn't crash, does nothing):
@ QPalette palette = (*lines[i]).palette();
palette.setColor(QPalette::WindowText,generateColour(i)); //Generates a valid colour
(*lines[i]).setPalette(palette);@Can you help me, please?
-
wrote on 14 Nov 2013, 00:55 last edited by
You should use stylesheet. Parts of QPalette will be ignored by some modern style such as XP/Vista/MacOS
-
wrote on 14 Nov 2013, 06:07 last edited by
I'm not using newer Windows or Mac, I am using Linux, but it seems that the palette is ignored anyway. I'll try that stylesheet, I hope that I was wrong when reading that it can't be used.
-
maybe you use the wrong palette role. Did you try QPalette::ButtonText or QPalette::Text?
I can't remember which roles assign which color and i never will i think ... :) -
wrote on 14 Nov 2013, 18:06 last edited by
@1+1=2
I could only change the background colour, though, changing the text colour or anything else didn't seem to work (just did nothing). I think that linux's window manager is to blame.@raven-worx
I had tried also the palette roles you suggested, but neither of them had any effect. Style sheet was the only thing capable of colouring something on these checkboxes.Thanks for the help. Is there a way to give you a kudos?
2/5