At 08:26 08/02/2006 -0900, 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

Funny this example works as expected:

from PyQt4.QtCore import *
from PyQt4.QtGui import *

class AllGreen(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        layout = QVBoxLayout(self)

        self.w1 = QLineEdit(self)
        self.w2 = QLineEdit(self)
        self.w3 = QLineEdit(self)

        palette = self.palette()
        role = self.backgroundRole()
        palette.setColor(role, QColor('green'))
        self.setPalette(palette)

        palette1 = self.w1.palette()
        role = self.w1.backgroundRole()
        palette1.setColor(role, QColor('red'))
        self.w1.setPalette(palette1)

        palette2 = self.w2.palette()
        role = self.w2.backgroundRole()
        palette2.setColor(role, QColor('yellow'))
        self.w2.setPalette(palette2)

        palette3 = self.w3.palette()
        role = self.w3.backgroundRole()
        palette3.setColor(role, QColor('red'))
        self.w3.setPalette(palette3)
        layout.addWidget(self.w1)
        layout.addWidget(self.w2)
        layout.addWidget(self.w3)

def testWidget():
    import sys
    a = QApplication(sys.argv)
    QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))

    w = AllGreen()
    w.show()
    a.exec_()

if __name__ == "__main__":
    testWidget()

************************************************************
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
************************************************************

_______________________________________________
PyKDE mailing list    [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to