第一步给窗体设置属性:
setWindowFlags(Qt::FramelessWindowHint );
setAttribute(Qt::WA_TranslucentBackground);
第二部重写paintevent 方法:
void LoadingDialog::paintEvent(QPaintEvent* p)
{
QPainter painter(this);
painter.fillRect(this->rect(), QColor(255, 255, 255, 25)); //QColor最后一个参数25代表背景的透明度,数值越小,越透明
}