//设置窗体透明
this->setAttribute(Qt::WA_TranslucentBackground, true);
//设置无边框
this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint);
QVBoxLayout* pMainLay = new QVBoxLayout(this);
CLoginRealWidget* pRealWidget = new CLoginRealWidget(this);
pMainLay->addWidget(pRealWidget);
pMainLay->setContentsMargins(30, 30, 30, 30);
setLayout(pMainLay);
//给顶层widget设置背景颜色,不然看不见,因为底层widget已经透明了
pRealWidget->setStyleSheet("background-color:rgb(255, 254, 253)");
QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect(this);
//设置阴影距离
shadow->setOffset(0, 0);
//设置阴影颜色 686868
shadow->setColor(QColor("#686868"));
//设置阴影区域
shadow->setBlurRadius(30);
//给顶层QWidget设置阴影
pRealWidget->setGraphicsEffect(shadow);
#include <QGraphicsDropShadowEffect>
QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect(this);