[PyKDE] PyQt4: setPaletteBackgroundColor

V. Armando Sole sole at esrf.fr
Wed Feb 8 08:53:04 GMT 2006


Hi,

At 14:11 07/02/2006 -0900, you wrote:
>I relaize that this is a question for qt-interest, but I'm getting a slow 
>response.
>
>What is the preferred method for setting the background color of a widget 
>in qt4? I'm using palette().setColor(QPalette.Window, mycolor)), but this 
>setting for child widgets seems to be overriden by the color you set the 
>parent widget with. Are you supposed to draw a rect in paintEvent()? The 
>QWidget docs don't seem to say much.

I am using this for changing the background color in QLineEdit widgets and 
so on (self is a QLineEdit derived class). You can give a try:

     def setPaletteBackgroundColor(self, color):
             palette = self.palette()
             role = self.backgroundRole()
             palette.setColor(role,color)
             self.setPalette(palette)

It is almost what you are doing. Could it be you are not giving the 
appropriate role?

Regards,

Armando
************************************************************
V. A. Solé
ESRF - BLISS Group PHONE: +33 (0)4 76 88 25 84
BP 220                     FAX:       +33 (0)4 76 88 25 42
38043 - Grenoble Cedex
France
************************************************************




More information about the PyQt mailing list