How to put png image with transparent background in QToolButton

I want to put a png image as a background in a QToolButton. But I can not get the transparent parts in the button. In my QToolButton, the transparent parts appear as white. Can anyone suggest how to remove the white parts as transparent?

+3
source share
1 answer

I assume something is wrong with your png file. The following code:

QToolButton button;
button.setIcon(QIcon("E:/delete.png"));
button.setIconSize(QSize(256, 256));
button.show();

works fine for me (of course, E: /delete.png has a transparent background).

Make sure you keep transparency for your png.

+4
source

Source: https://habr.com/ru/post/1741903/


All Articles