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;

posted @ 2014-08-22 10:50  北山愚公*  阅读(7636)  评论(0编辑  收藏  举报