QPushButton background color not working
I'm trying to color the background of a QPushButton, but it does not work.
QPushButton* blau = new QPushButton("Blau", &F);
QPalette pal_blau = blau->palette();
Using gnome 2.28.2 on Centos 6.3
It seems that there is a little border in blue around the button, but the button background has no color changed.
Shouldn't you try it using the stylesheet? Much easier and can be done in designer.
I would like to do it using QPalette
Change line 3 with :
It does not work either :/
Well, I think for settings buttons background color, style sheet is the way to go ... (I think Qt use OS theme effect, hence some palette modifications don't have any effect)
The documentation on QPalette states:
Warning: Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines. This is the case for both the Windows XP, Windows Vista, and the Mac OS X styles.[/quote]
So, basically, most rendering on popular, modern OS's bypasses the palette completely.
Using style sheets really is the only relyable way.
Maybe this helps you out: "How_to_Change_the_Background_Color_of_QWidget":http://qt-project.org/wiki/How_to_Change_the_Background_Color_of_QWidget