实现的效果:
- 正常状态下:黑底(背景色),白字(前景色),圆角,向外凸起;
- 鼠标停留:背景和前景都反色;
- 鼠标按下:背景色变为淡蓝色,向内凹陷;
class MyStyleSheet: @staticmethod def button_style(): # 正常状态下:黑底(背景色),白字(前景色),圆角,向外凸起 # 鼠标停留:背景和前景都反色 # 鼠标按下:背景色变为淡蓝色,向内凹陷 button_style = ("QPushButton{background-color:black; color:white; border-radius:10px; border:2px groove gray; border-style:outset;}" "QPushButton:hover{background-color:white; color:black;}" "QPushButton:pressed{background-color:rgb(85, 170, 255); border-style:inset; }") return button_style