qtqtstylesheetsqpushbuttonqpalette

How to change the focus color (highlight color) of QPushButton


How do I change the focus color of a pushbutton as here:

I also changed the background color of the button, and the palette, but still no change occurred.


Solution

  • Use stylesheets:

    QPushButton:focus:pressed{ background-color: some_colour; }
    QPushButton:focus{ background-color: some_other_colour; }
    

    You can either use Qt Creator to add the styles to your button, or load them inside your code by calling setStyleSheet("...") on your button.