I fiddle with this and got it working for the most part, thanks for the info.

However, I have found one thing where it doesn't work: QTextEdit objects don't seem to follow the palette setup. I have the same code for the TextEdits and the LineEdits (it's a "ui_good(self, ui_object)" and "ui_bad(self, ui_object)" type function, where self is the container and ui_object is the object to change color. The code looks pretty much like what you have below. When a LineEdit is passed, it will change red with ui_bad, and the light/pastel blue that is in the windows default palette (my default text background) when I pass it to ui_good. When a TextEdit is passed, there is no change.

I haven't tested it on my BSD machine yet (to see if it's a windows only error).

Any idea on that one?
Thanks,
-Jim Stapleton

----- Original Message ----- From: "Doug Bell" <[EMAIL PROTECTED]>
To: "Steven James Samuel Stapleton" <[EMAIL PROTECTED]>
Sent: Monday, January 15, 2007 9:46 AM
Subject: Re: [PyKDE] changing background color of QTextEdit/QLineEdit


>It's not difficult.  Check the Qt documentation for the QWidget.palette
>property and for the QPalette class.  The class lets you get
>(QPalette.color()) and set (QPalette.setColor()) the color for various
>color groups and color roles.  The groups let you set colors for active
>(focused) and inactive states, and the roles for Text (foreground) and
>Base (background).
>
>Doug.

So, that only effects the widget and not the whole app?

Yes, as long as you use QWidget.setPalette() and not
QApplication.setPalette().  Remember that your QLineEdit inherits from
QWidget, so your code might look something like this:

  editor = QLineEdit()
  palette = editor.palette()
  palette.setColor(QPalette.Active, QPalette.Text, QColor(255, 0, 0))
  palette.setColor(QPalette.Active, QPalette.Base, QColor(50, 50, 50))
  editor.setPalette(palette)

Doug.


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

Reply via email to