1

I'm looking at making a QWidget partially transluscent.

QWidget::setMask can set a per-pixel transparency, like this, but it's either-or: not transluscent.

QWidget::opacity can set a global transluscency, but it's not per-pixel.

How can I get the best of both worlds and add a per-pixel alpha channel to the whole widget? (Decorations don't matter.)

spraff
  • 32,570
  • 22
  • 121
  • 229
  • 1
    Possible duplicate: http://stackoverflow.com/questions/1333610/displaying-translucent-irregular-shaped-windows-with-qt and for the per-Pixel part you can paint a `QPixmap` with an alpha channel as the background. – alexisdm Oct 13 '11 at 17:30
  • Have to agree with the above comment. Follow the setup in the link above and paint what you want in the paint event. – Trenton Schulz Oct 13 '11 at 18:33

2 Answers2

0

Maybe QWidget::setMaks()?

QLabel topLevelLabel;
QPixmap pixmap(":/images/tux.png");
topLevelLabel.setPixmap(pixmap);
topLevelLabel.setMask(pixmap.mask());
k06a
  • 17,755
  • 10
  • 70
  • 110
0

It looks like the QStyle class is what you might be looking for, esp. QStyle::drawItemPixmap; then use QWidget::setStyle(). Never used this myself though.

Matt Phillips
  • 9,465
  • 8
  • 44
  • 75