How to add picture containing transparency to the window background using code?

Viewed 24

How to set a png file containing transparency to the window background

using only code and not css/stylesheet?

With the following code the picture is added however, the background became black in the parts where the image is not painted

ui.setupUi(this);

QPixmap bkgnd(":/pic");
//bkgnd = bkgnd.scaled(this->size(), Qt::IgnoreAspectRatio);

//bkgnd.fill(Qt::transparent);

QPalette palette;
//palette.setColor(QPalette::Window, Qt::transparent);
palette.setBrush(QPalette::Window, bkgnd);

this->setPalette(palette);
//this->setAttribute(Qt::WA_TranslucentBackground, true);

Commented are things i already tried.

0 Answers
Related