QPixmap and Opacity and Transparency
Unsolved
General and Desktop
-
Hi,
I want to know how to set the transparency and opacity of a pixmap. for example I want to set the opacity and transparency of a cover art to 50% and amke it a QListView's background image
Can anyone tell me how to do this? -
-
Hi @Ni-Sumi
Where sohuld I do this? to the main window? to the listview? -
Hi @shahriar25 ,
It is some thing like this,
QPixmap input("YourImage.png");
QImage image(input.size(), QImage::Format_ARGB32_Premultiplied); //Image with given size and format.
image.fill(Qt::transparent); //fills with transparent
QPainter p(&image);
p.setOpacity(0.2); // set opacity from 0.0 to 1.0, where 0.0 is fully transparent and 1.0 is fully opaque.
p.drawPixmap(0, 0, input); // given pixmap into the paint device.
p.end();