控件添加和删除阴影

2022-11-16  本文已影响0人  lk_erzanml
def add_shadow(self, button):
    # 添加阴影
    self.effect_shadow = QGraphicsDropShadowEffect(self)
    self.effect_shadow.setOffset(5, 5)  # 偏移
    self.effect_shadow.setBlurRadius(5)  # 阴影半径
    self.effect_shadow.setColor(QColor('#000000'))  # 阴影颜色
    button.setGraphicsEffect(self.effect_shadow)  # 将设置套用到button窗口中

def del_shadow(self,button):#删除阴影
    self.effect_shadow = QGraphicsDropShadowEffect(self)
    self.effect_shadow.setOffset(0, 0)  # 偏移
    self.effect_shadow.setBlurRadius(0)  # 阴影半径
    self.effect_shadow.setColor(QtCore.Qt.blue)  # 阴影颜色
    button.setGraphicsEffect(self.effect_shadow)  # 将设置套用到button窗口中
上一篇 下一篇

猜你喜欢

热点阅读