可以用QGraphicsDropShadowEffect来实现软件界面边缘阴影效果,不过要慎用,因为该效果占用的CPU太大了,会使软件变得卡顿。
this->setGeometry(0, 0, 1550, 900);
this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setWindowFlags(Qt::FramelessWindowHint);
widget=new QWidget(this);
widget->setGeometry(5,5,1540,890);
widget->setStyleSheet("border-radius:10px;");
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(10);
effect->setOffset(0, 0);
this->setGraphicsEffect(effect);