//label组件
def add_shadow(self,label):
# 添加阴影
self.effect_shadow = QGraphicsDropShadowEffect(self)
self.effect_shadow.setOffset(0,0) # 偏移
self.effect_shadow.setBlurRadius(30) # 阴影半径
self.effect_shadow.setColor(QtCore.Qt.gray) # 阴影颜色
button.setGraphicsEffect(self.effect_shadow) # 将设置套用到label窗口中
//button组件
def add_shadow(self,button):
# 添加阴影
self.effect_shadow = QGraphicsDropShadowEffect(self)
self.effect_shadow.setOffset(0,0) # 偏移
self.effect_shadow.setBlurRadius(30) # 阴影半径
self.effect_shadow.setColor(QtCore.Qt.gray) # 阴影颜色
button.setGraphicsEffect(self.effect_shadow) # 将设置套用到button窗口中
使用的时候调用这个函数
self.add_shadow(自己组件的名称)
实现效果