Important: Please read the Qt Code of Conduct -

QPushButton:pressed not applied if stylesheet on parent

  • Hi,

    So I'm having troubles with stylesheets. I want to change the background of a button if it's pressed.
    When I put the qss for QPushButton:pressed on the button itself everything works fine, but if I put it on the QMainWindow or another parent of the button(s), it doesn't work and the background color just stays the same when it is pressed.

    Any ideas how I could make this work or is it a bug?

    Note: hover works when applied through the main windows' stylesheet.

  • Hi, I figured it out myself...
    If i put the pressed qss after the hover qss everything works as expected. Seems like the hover color just stays there if it's the latest entry in the stylesheet.

Log in to reply