PyQt QPushButton Background color

后端 未结 2 1144
长发绾君心
长发绾君心 2020-12-18 22:01

I have the follow code:

self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(0, 550, 150, 31))
self.pushButton.setObjectName(_f         


        
相关标签:
2条回答
  • 2020-12-18 22:20

    You can change the style of the button:

    self.pushButton.setStyleSheet("background-color: red")
    

    It's like CSS.

    0 讨论(0)
  • 2020-12-18 22:22

    Here is a sample code. You can choose any style to set background color.

    QPushButton button1, button2, button3;
    
    button1.setStyleSheet("background-color: red");
    
    button2.setStyleSheet("background-color:#ff0000;");
    
    button3.setStyleSheet("background-color:rgb(255,0,0)");
    
    0 讨论(0)
提交回复
热议问题