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:
    0_1529944422963_0d03a4c0-4f20-470c-89c6-9c39fcbd4513-image.png

    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