Ilya Voronin
Ilya Voronin

Reputation: 21

QLabel becomes black instead of transparent

I have QLabel and I want to make it transparent(semi-transparent actually). The only thing that works for me is setWindowOpacity(0.5). But it makes text transparent too.

I've tried:

  1. setStyleSheet("QWidget{background-color: transparent;}")
  2. setStyleSheet("background-color: rgba(0,0,0,0)")
  3. setAttribute(Qt::WA_TranslucentBackground, true);
  4. setAttribute( Qt::WA_OpaquePaintEvent, true );

But window becomes black and i have no idea why. My os windows 10 x64.

Upvotes: 0

Views: 1770

Answers (1)

Ilya Voronin
Ilya Voronin

Reputation: 21

I added this->setWindowFlags(Qt::FramelessWindowHint);
And now this->setAttribute(Qt::WA_TranslucentBackground, true); works.

Upvotes: 2

Related Questions