How to change QPushButton text and background color

For those who still want to change color of button with the instruction

button.setStyleSheet('QPushButton {background-color: #A3C1DA}')

and not able to do so, just modify the above instruction to

button.setStyleSheet('QPushButton {background-color: #A3C1DA; border:  none}')

And it will change the button color, so the trick is to remove the border


Apart from some inconsistencies with your code example setting the background color and text color of a QPushButton works just fine with:

setStyleSheet('QPushButton {background-color: #A3C1DA; color: red;}')

Example (using PySide):

from PySide import QtGui

app = QtGui.QApplication([])

button = QtGui.QPushButton()
button.setStyleSheet('QPushButton {background-color: #A3C1DA; color: red;}')
button.setText('Press Me')
menu = QtGui.QMenu()
menuItem1 = menu.addAction('Menu Item1')
menuItem2 = menu.addAction('Menu Item2')

button.setMenu(menu)
button.show()

app.exec_()

results in:

enter image description here