[PyKDE] PyQt4: setPaletteBackgroundColor

David Boddie david at boddie.org.uk
Wed Mar 29 13:00:31 BST 2006


On Wed Mar 29 02:19:36, Patrick Stinson wrote: 
 
> this is interestin because the palette still doesn't propogate to 
> the widgets' children. 
>  
> """ 
> A common base class for all pk widgets. 
> """ 
>  
> from PyQt4.QtGui import QFrame, QPalette 
>  
>  
> class PKWidget(QFrame): 
>     """ Conveinience class """ 
>     def set_background(self, color): 
>         palette = QPalette() 
>         palette.setColor(QPalette.Window, color) 
>         palette.setColor(QPalette.Background, color) 
>         self.setPalette(palette) 
 
See the following page for more information about this: 
 
http://doc.trolltech.com/4.1/qwidget.html#transparency-and-double-buffering 
 
Basically, in Qt 4.1, you need to call setAutoFillBackground(True) 
to be able to customize the background colour of standard widgets 
like QFrame and subclasses that don't provide their own 
implementation of paintEvent(). 
 
However, you should be able to set the background color in a parent 
widget and, even if the parent doesn't display a background, any 
children that do should inherit that from the parent. 
 
David 


___________________________________________________________
$0 Web Hosting with up to 200MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com




More information about the PyQt mailing list