参考:Qt之QGraphicsDropShadowEffect_unknown type name 'qgraphicsdropshadoweffect-CSDN博客
示例1:?
QWidget w1;
QPushButton *pushBtn = new QPushButton("test",&w1);
pushBtn->move(10,10);
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect;
shadowEffect->setOffset(5, 5);//设置偏移
shadowEffect->setBlurRadius(5);//设置模糊半径
shadowEffect->setColor(QColor(0, 0, 200, 200));//设置颜色
pushBtn->setStyleSheet("QPushButton {background-color: red}");
pushBtn->setGraphicsEffect(shadowEffect);
w1.show();
示例2:?
Qt图形特效:QGraphicsDropShadowEffect-CSDN博客
shadowEffect->setOffset(20, 20);//设置偏移
示例3:
pushBtn = new QPushButton("test",this);
pushBtn->move(10,10);
pushBtn->resize(200,100);
QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect;
shadowEffect->setOffset(0, 0);//设置偏移
shadowEffect->setBlurRadius(15);//设置模糊半径
shadowEffect->setColor(Qt::red);//设置颜色
pushBtn->setStyleSheet(".QPushButton{background-color:#FFFFFF;border-radius:6px;}");
pushBtn->setGraphicsEffect(shadowEffect);