laurent
laurent

Reputation: 90863

How to draw a QPixmap with transparency

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?

Upvotes: 5

Views: 10888

Answers (1)

Martin Beckett
Martin Beckett

Reputation: 96167

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

Upvotes: 5

Related Questions