PDA

View Full Version : How to change color of a QPushButton?



vishal.chauhan
5th March 2008, 11:07
Hi All,

I am working on Qt 4.3.3 on my Mac 10.4.11.

I have a QPushButton and I want that its color should not be white as the default color.
so how should I change the color of the QPushButton also when I checked it the selected color is aqua so I also want to change that color.

So how should I do it?

Thanks.
Vishal

jpn
5th March 2008, 11:10
Please search the forums before starting new threads. This question has been answered many many times.

wysota
5th March 2008, 12:00
I made a FAQ entry for that: http://www.qtcentre.org/forum/faq.php?faq=qt_general_category#faq_qt_button_colo r

vishal.chauhan
5th March 2008, 12:28
I am using the code method.

That is I am setting like this

btn_Show->setStyleSheet("color: #0000dd; background-color: red;");


But nothing changes. I am drawing the custom Button(just implementing the enter and leave event).

As I reading setStyleSheet it does not support QMacStyle so Is there any other way I can achieve this.

wysota
5th March 2008, 12:44
Did you reimplement the paintEvent? Could you show us the code?

vishal.chauhan
5th March 2008, 12:56
Actually it does not support on QMacStyle if I changes the style to some other style the color changes but I need this on QMacStyle.

wysota
5th March 2008, 13:22
Change the style of this particular widget then. All the rest of the application will remain unchanged.