找到相应的按钮,如 pushButton
self.pushButton.setStyleSheet('''QPushButton{background:#F7D674;border-radius:5px;}QPushButton:hover{background:yellow;}''')
当鼠标不在按钮上时,按钮颜色为:#F7D674,当鼠标指向按钮时,其颜色为:yellow
相应地,我们可以设置第二个按钮的颜色:
self.pushButton_2.setStyleSheet('''QPushButton{background:#6DDF6D;border-radius:5px;}QPushButton:hover{background:green;}''')
<