//設置窗體透明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);//設置陰影顏色 686868shadow->setColor(QColor("#686868"));//設置陰影區域shadow->setBlurRadius(30);//給頂層QWidget設置陰影pRealWidget->setGraphicsEffect(shadow);
#include <QGraphicsDropShadowEffect>
QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect(this);