PDA

View Full Version : Background Color of QToolButton or QPushButton



metdos
28th August 2009, 13:33
When I changed a QToolButton or QPushButton's background color by using StyleSheet, I lose button effects and they seem like labels.
Do you have any idea, how can I change colors of QToolButton and QPushButton without losing button effects?

Thanks.

yogeshgokul
28th August 2009, 13:50
You cannot control that. This happens with style sheet. For better results use different background colors for normal, hover, pressed. So it will look better.;)
More info here (http://pepper.troll.no/s60prereleases/doc/stylesheet-examples.html#customizing-a-qpushbutton-using-the-box-model).

Lykurg
28th August 2009, 13:55
That's wired. Can't reproduce your problem. Have you tried QPalette for changing the color?

Edit: you mean the appearance, not the functionality. Of course you get a flat button if you set the color via style sheets. That's the wanted effect. But as said use QPalette.

metdos
28th August 2009, 13:58
No, I didn't try QPalette, I'm using StyleSheet for other changes and I want to change everthing in same way.

yogeshgokul, thanks for the link.


That's wired. Can't reproduce your problem. Have you tried QPalette for changing the color?

Lykurg
28th August 2009, 14:01
No, I didn't try QPalette, I'm using StyleSheet for other changes and I want to change everthing in same way.

If so and you want to have a 3d effect on the buttons you have to use images (or use gradients if they fit your needs).

Hardstyle
17th June 2010, 12:02
if you want to change the stylesheet only for qtoolbutton u write qApp->setStyleSheet("QToolButton{....css...}")
qtool button inherts qpushbutton so if u want to have different css...1st style the qpushbutton and after the qtoolbutton....it will work..i hope..(sry for my english)