pyqt5点击按钮更换图片

self.pictureButton_1.setFixedSize(10, 10)
self.pictureButton_2.setStyleSheet(
            '''QPushButton{background:#FFFFFF;border-radius:5px;}QPushButton:hover{background:red;}''')
    def changePicture1(self):
        self.pictureButton_1.setStyleSheet('''QPushButton{background:#FF0000;border-radius:5px;}''')
        self.pictureButton_2.setStyleSheet('''QPushButton{background:#FFFFFF;border-radius:5px;}''')
        self.pictureButton_3.setStyleSheet('''QPushButton{background:#FFFFFF;border-radius:5px;}''')
        self.pictureButton_4.setStyleSheet('''QPushButton{background:#FFFFFF;border-radius:5px;}''')
        self.label.setPixmap(QtGui.QPixmap("images/carousel/1.png"))

点击按钮之后,其他按钮变成白色,被点击按钮变为红色,并且更换图片,图片是在label组件中显示

你可能感兴趣的:(pyqt5)