Alen
Alen

Reputation: 1788

Qt Window with transparent background image

I placed background image like this:

setWindowFlags(Qt::FramelessWindowHint);

    QPixmap slika("some_image.png");
    QPalette paleta;
    paleta.setBrush(this->backgroundRole(), QBrush(slika));
    this->setPalette(paleta);

If I make this picture transparent, when application loads, it will only blink and disappear. But if I make this image with no transparency, then everything is ok. Why Qt refuses to use transparent image?

Upvotes: 1

Views: 2946

Answers (1)

Aamir Abro
Aamir Abro

Reputation: 858

I don't know what is your use case for this, but you can also try using setStyleSheet method to make background transparent.

setStyleSheet("background:transparent;");
setAttribute(Qt::WA_TranslucentBackground);
setWindowFlags(Qt::FramelessWindowHint);

Hope this helps.

Upvotes: 1

Related Questions