ui->setupUi(this); ui->frame->setStyleSheet("QFrame{background-color: rgb(255, 255, 255);border-radius:1px}"); QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this); effect->setOffset(0, 0); effect->setColor(Qt::black); effect->setBlurRadius(22); ui->frame->setGraphicsEffect(effect); this->setAttribute(Qt::WA_TranslucentBackground);//父布局设置为透明
.ui文件中增加frame控件,与父布局增加一些边距,然后再设置上边这一段代码。