[PyKDE] (no subject)
David Boddie
david at boddie.org.uk
Wed Feb 8 18:19:51 GMT 2006
On Wed Feb 8 18:26:28 MET 2006, Patrick Stinson wrote:
>Yeah, I"m getting the same problem. If you set the role color for
>the child widget, and set the role color for the parent widget,
>the child widget just gets the color for the parent widget. This
>means that you can't give child widgets their own color. For
>example, the following code shows no red
I'm guessing that this is with Qt 4.1.0.
[Quoting as originally written]
class AllGreen(QWidget):
def __init__(self):
QWidget.__init__(self)
self.w = QWidget(self)
self.w.setFixedSize(100, 100)
palette = self.w.palette()
role = self.w.backgroundRole()
palette.setColor(role, QColor('red'))
self.w.setPalette(palette)
palette = self.palette()
role = self.backgroundRole()
palette.setColor(role, QColor('green'))
self.setPalette(palette)
You can make the child widget visible by adding the following
line:
self.w.setAutoFillBackground(True)
Contents propagation is enabled by default in Qt 4.1.0. For custom
widgets where you reimplement QWidget's paintEvent(), you can do
various things to allow effects like partial transparency for child
widgets while still adding your own colour scheme. However, a plain
QWidget has to draw itself, so this seems like the quickest way to
get what you want.
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