#include <QPainter>
//构造函数设置如下两个属性
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackGround);
//重写paintEvent函数
void paintEvent(QPaintEvent *event)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
p.fillRect(rect(),QColor(0,0,0,153));
style()->drawPrimitive(QStyle::PE_Widget,&opt,&p,this);
}