用qt怎么给widget 添加背景
给两个小例子呗 需要哪些类 用什么函数
[解决办法]
QPixmap pix; pix.load("./image/1.jpg",0,Qt::AvoidDither
[解决办法]
Qt::ThresholdDither
[解决办法]
Qt::ThresholdAlphaDither);
QWidgetWindow = new QWidget();
QWidgetWindow ->show();
QWidgetWindow ->resize(pix.size());//设置窗口的大小和图形一样
QWidgetWindow ->setMask(pix.mask());//设置窗口的形状和图形一样
//设置窗口的背景和图形一样
QFrame *frame = new QFrame(PlayListWindow);
frame->resize(pix.size());
QPixmap pixmap = pix .scaled(pix.size());
QPalette palette;
palette.setBrush(frame->backgroundRole(),QBrush(pixmap));
QWidgetWindow->setPalette(palette);