I have the follow code:
self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(0, 550, 150, 31))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
How do I get the background color of this button to change. I have tried using Palette and I am having no success. I would like the color to be red. I can't seem to call it correctly. Any help would be great.
You can change the style of the button:
self.pushButton.setStyleSheet("background-color: red")
It's like CSS.
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)");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With