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;
Qt的QPixmap半透明
时间: 2024-10-12 12:41:04