PDA

View Full Version : How to change defualt color of QCheckbox box?



darshan.hardas
23rd October 2008, 13:29
I want to change the default color of QCheckbox box (base ).

I have tried with
QPalette p;
p.setColor(QPalette::Base, QColor(255,0,0));
qCheckBox.setPalette(pal);


The above code works in Qt 4.3.3 with Qt3Support
Please guide me how to implement for Qt 4.4

eehmke
9th November 2008, 13:29
For QCheckbox you need to use the QPalette::Button role as background. You can set the color roles by:
setBackgroundRole (QPalette::Button);
setForegroundRole (QPalette::ButtonText);
and use them by:
pal.setColor (backgroundRole(), background_color);

caduel
9th November 2008, 14:08
have a look at style sheets: stylesheet

darshan.hardas
12th November 2008, 13:24
Hi,

To set the user-defined colors in the base of QCheckBox, I have to set the style as
qCheckBoxObj->setStyle(new QWindowStyle);

And also,
QPalette p;
p.setColor(QPalette::Base, QColor(255,0,0));
qCheckBox.setPalette(pal);

The color is seen in my case.

Thanks for your replies......