PDA

View Full Version : QPalette on PushButton



wagmare
30th January 2009, 12:42
hi friends,
i try to display different color with respect to the input ..

so to set the color value i use three variable rd , gr , bl and i use it as QColor(rd,gr,bl)

using i program as



QPalette p;
p.setColor(QPalette::Background,QColor(rd,gr,bl));
Button->setPalette(p);
1Button->setPalette(p);
2Button->setPalette(p);
3Button->setPalette(p);
1Label->setPalette(p);
2Label->setPalette(p);
1Label->setPalette(p);
2Label->setPalette(p);


here all the labels are displaying the color but
pushButtons are not displaying the background colors ... why?

i enabled the autofillBackground() also ... if it is not possible then there is any other way to change the color effect according to input ie using a variable for setting color ... ?

please help
thanks in advance

jpn
30th January 2009, 13:03
Open QPalette docs and take a look at the picture. You should use QPalette::Button. You could also have searched the forums....

PS. Your profile says "X11" so I won't even mention about the famous XP problem.

wagmare
30th January 2009, 13:09
thanks for reply
just a minute before i solve seeing docs clearly

Button->setPalette(QPalette(QColor(rd,gr,bl)));

is working fine ....

wagmare
30th January 2009, 13:44
but the document says
use the colors in the palette rather than hard-coding specific color

so is there any other way to change the color of the QPushButton using variable color values at differtent times ...
please help
thanks in advance