Important: Please read the Qt Code of Conduct -

How to correctly set push button style when pressed?

  • Hello, I'm new to Qt and I'm using Qt Designer.

    My Problem is:
    I'm unable to set a style to a push button when it is pressed. See the image below:

    The stylesheet pressed state has no effect on the button, does anyone see what I am doing wrong?

    Thank you for your time, have a good day!

  • @testevpsa Hi,

    Maybe your first 4 lines overrides the other definitions because they are global. Try to enclose them in QPushButton{...}

    QPushButton {
        background-color: rgb(51, 153, 204);
    QPushButton:pressed {
        background-color: rgb(224, 0, 0);

  • Hello @Gojir4 , you are completely right!
    Thank you for your help!

Log in to reply