pyqt5点击按钮更换图片

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/sinat_36188088/article/details/102660900
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组件中显示

猜你喜欢

转载自blog.csdn.net/sinat_36188088/article/details/102660900