#include <QMouseEvent>
#include <QPainter>
#include <QPixmap>
#include <QBitmap>
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
QPixmap pix;
/*
以下四行代码,任意一行都是有效的
*/
pix.load("D:\\VS\\qtCreator\\ShapeWidget\\puppy.png", 0, Qt::AvoidDither);
//pix.load("D:\\VS\\qtCreator\\ShapeWidget\\puppy.png",0, Qt::ThresholdAlphaDither);
//pix.load("D:\\VS\\qtCreator\\ShapeWidget\\puppy.png", 0, Qt::ThresholdDither );
//pix.load("D:\\VS\\qtCreator\\ShapeWidget\\puppy.png", 0, Qt::AvoidDither | Qt::ThresholdAlphaDither | Qt::ThresholdDither );
resize(pix.size());
setMask(QBitmap(pix.mask()));
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::paintEvent(QPaintEvent* event) {
QPainter painter(this);
painter.drawPixmap(rect(),QPixmap("D:\\VS\\qtCreator\\ShapeWidget\\puppy.png"),QRect());
}
超级简单的不规则轮廓的对话框的实现
猜你喜欢
转载自blog.csdn.net/shensheng100221/article/details/103672240
今日推荐
周排行