Adding a Pad to a QPushbutton Disabled Animation Style Sheet

When I add an add-on to the QPushButton stylesheet, the animation does not appear when the button is clicked, release:

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

Thus, I mean that the button text is not immersed.

This is normal?

+3
source share
2 answers

it is impossible to add a registration and see how the text enters it. The only way I could see this, and I did not try, would be to translate the text to the right and bottom on the pressed sub-control, but which remains to be verified.

+2
source

You need to define at least a pseudo-state pressed. 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 the Qt documentation: Configuring QPushButton

+2
source

Source: https://habr.com/ru/post/1747440/


All Articles