posted on: 2008-11-05 11:30:49
This is a concise and correct way to set a background color of a widget.

>I am doing this under the consideration that my widget is inside of another widget, so I want to change its background color without changing the background color of everything else.

pal = QtGui.QPalette(widget.pallet())
widget.setAutoFillBackground(True)
pal.setColor(QtGui.QPalette.Window,QtGui.QColor('white'))
widget.setPalette(pal)

Is isn't nescessary to copy the original pallet, but I do just incase there are other settings you might want to keep.

Comments

Name: