Important: Please read the Qt Code of Conduct -

What's the best way to style a QPushButton? Setting background image or setting an icon?

  • I'm trying to create a styled button with an svg file I have. I'd like it to have some sort of simple animation when the button is clicked (turning slightly darker or something). Is it better to set the svg as the background image in the button's stylesheet? Or is setting the svg as the button icon better? What are the differences? What's the best way to get the 'click' animation I'm going for? I'm using Qt Designer for this. Any help is much appreciated!

  • Lifetime Qt Champion


    IIRC, the fastest way to do it is through style sheet like described here. Or a QProxyStyle.

  • Cool, thanks for your response! Do you know what the difference is between using background-image in a stylesheet and using set-icon?

  • Lifetime Qt Champion

    The buttons are designed to handle icons like show in the documentation, a background image as the name suggests will be put in the image as background of the widget.

Log in to reply