5

I've got a QPixmap and I would like to draw it on a QWidget. However, I would like to make it 50% transparent so that the background can be seen below. How can I do that?

laurent
  • 88,262
  • 77
  • 290
  • 428

1 Answers1

5

You set the compositionmode in the QPainter and then either use a mask to define which bits of the iage are transparent or use QImage::Format_ARGB32_Premultiplied type for the image with the alpha channel set.

See the example http://doc.qt.io/archives/4.6/demos-composition.html

Christophe Weis
  • 2,518
  • 4
  • 28
  • 32
Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • 10
    Actually I found that it's possible to simply call `painter.setOpacity(0.5)` just before drawing the pixmap, but thanks anyway. – laurent Aug 09 '11 at 06:25