[PyQt] button color

K.Wegner at herts.ac.uk K.Wegner at herts.ac.uk
Sun Jul 15 15:02:24 BST 2007


Hi, in my program the user presses a button and gets the color dialog where 
he can choose a color. after that I want to change the color of this button 
to the new color but only the border is set to a new color and not the 
background of the button. (PyQt4 and Qt 4.2.1, Linux and Windows)

newColor = QColorDialog.getColor(self.color)
if (newColor.isValid()):
   self.color = newColor
   palette = QPalette()
   palette.setColor(QPalette.Button, self.color)
   self.colorButton.setPalette(palette)
   self.colorButton.setAutoFillBackground(TRUE)
   Btw it worked fine with Qt3.

Thanks for your help.
Katja 


More information about the PyQt mailing list