首页 > 代码库 > Qt的QPixmap半透明

Qt的QPixmap半透明

QPixmap pix1(":/PixmapTest/Resources/Chrysanthemum.jpg");

QPixmap temp(pix1.size());
temp.fill(Qt::transparent);

QPainter p1(&temp);
p1.setCompositionMode(QPainter::CompositionMode_Source);
p1.drawPixmap(0, 0, pix1);
p1.setCompositionMode(QPainter::CompositionMode_DestinationIn);
p1.fillRect(temp.rect(), QColor(0, 0, 0, 64));
p1.end();
pix1 = temp;