I'm trying to change the color of the combobox background. I want it to be white, but I can't make it have any color different from gray. The picture on top is what I'm getting, and the one on the bottom is what I'm after.
Here's my code:
from PyQt5 import QtWidgets, QtGui
class combodemo(QtWidgets.QWidget):
def __init__(self, parent = None):
super(combodemo, self).__init__(parent)
layout = QtWidgets.QHBoxLayout()
self.cb = QtWidgets.QComboBox()
self.cb.addItem("1")
self.cb.addItem("2")
pal = self.cb.palette()
pal.setColor(self.cb.backgroundRole(),QtGui.QColor(255,255,255))
self.cb.setPalette(pal)
self.cb.setAutoFillBackground(True)
layout.addWidget(self.cb)
self.setLayout(layout)
if __name__ == '__main__':
app = QtWidgets.QApplication([])
ex = combodemo()
ex.show()
app.exec_()