tags:

views:

154

answers:

2

When I add padding in a QPushButton's stylesheet the animation doesnt occur during button press,release:

QPushButton{ border: 1px solid green; padding: 2px; border-radius: 4px; }

By that, I mean the button text does not sink in.

Is this normal?

+1  A: 

You need to define at least the pressed pseudo state. For instance :

QPushButton{ border: 1px solid green; border-radius: 4px; }
QPushButton:pressed{ border: 2px solid green; padding-left : 2px;
                     padding-top : 2px;border-radius: 4px; }

See Qt documentation : Customizing QPushButton

Jérôme
This does not work I have already tried it.
yan bellavance
I edited my answer to solve the padding problem. It is strange if it doesn't work for you. On which platform and with which Qt version are you working ?I'm able to make it work on Mac Leopard and WinXP, with Qt 4.6.1.How are you setting the stylesheet on your button ? Are you using Designer ?
Jérôme
A: 

it is not possible to add padding and see the text sink in. The only way I could see it possible and I havent tried it would be to translate the text to the right and to the bottom on the pressed sub-control but that remains to be tested.

yan bellavance