yan bellavance
yan bellavance

Reputation: 4830

adding padding to the stylesheet of a QPushbutton disable animation

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?

Upvotes: 3

Views: 4527

Answers (2)

Jérôme
Jérôme

Reputation: 27027

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

Upvotes: 2

yan bellavance
yan bellavance

Reputation: 4830

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.

Upvotes: 2

Related Questions