大家好,我希望把图片设置成半透明的
参考资料
http://techbase.kde.org/Development/Tutorials/Graphics/Performancehttp://www.qtcn.org/bbs/read.php?tid=23583代码如下:
#include <QApplication>
#include <QPixmap>
#include <QPainter>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPixmap pixmap(":/imagess/house.png");
QPixmap temp(pixmap.width(), pixmap.height());
temp.fill(Qt::transparent);
QPainter p(&pixmap);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.drawPixmap(0, 0, pixmap);
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
p.fillRect(temp.rect(), QColor(0, 0, 0, 0.5));
p.end();
pixmap = temp;
QLabel *label = new QLabel;
label->setPixmap(pixmap);
label->show();
return app.exec();
}
程序运行后,没有显示图片,不知道怎么了,求高手指点。
谢谢!!!!