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点击按钮更换图片

 

上一篇:Qt鼠标悬停按钮样式表


下一篇:JMS微服务远程调用性能测试 vs .Net Core gRPC服务