PDA

View Full Version : button background color when it is clicked



navi1084
6th December 2008, 10:08
Hi,
I have placed some buttons which has seCheckable() state and SetAutodefault() state as true.

I want to change the back ground color when it is active and when the button is pressed and down.

I can change the color when it is active, but when it is clicked i want to change the background color of the button. i.e user should feel that button is pressed(down). when i use pressed or checked in my style sheet, the color changed only when mouse button is down.
so how can i change the background color when button is down state.untill user press other button or the current button comes up, button color shouldnt change

Thank You

spirit
6th December 2008, 10:47
try to use style sheets (http://doc.trolltech.com/4.4/stylesheet-syntax.html)


QPushButton:hover: pressed { color: blue; }

navi1084
6th December 2008, 11:01
I already used StyleSheets. Even i used QPushButton:hover: pressed { background-color: blue; }. Button will turn to blue when use press down and until mouse is in clicked state.. once you release the mouse it will be normal form.
But i need to differentiate clicked state and normal state using background color.

Thank You

navi1084
8th December 2008, 05:19
Can anyone help me out to resolve this :confused:

calmspeaker
9th December 2008, 16:02
try this


QString style_sheet_btn =" QPushButton:checked {background-color:rgb(255,100,100);border-style:solid;border-width:1.5px;border-color:gray;}";