[PyQt] set qlineedit red, easy?? SOLVED
Mads Ipsen
mpi at comxnet.dk
Thu Feb 5 12:45:40 GMT 2009
--------- Original Besked --------
Fra: Knapp <magick.crow at gmail.com>
Til: Frédéric <frederic.mantegazza at gbiloba.org>
Cc: pyqt at riverbankcomputing.com
Emne: Re: [PyQt] set qlineedit red, easy?? SOLVED
Dato: 05/02/09 13:11
> On Thu, Feb 5, 2009 at 12:50 PM, Frédéric
> <frederic.mantegazza at gbiloba.org> wrote:
> >
> > Le 5/2/2009, "Knapp" <magick.crow at gmail.com> a écrit:
> >
> >>I have a qlineedit that I want to turn the background red when the
> >>input is bad but I can't seem to find how to do this. I would
think it
> >>would be easy but it does not seem to be. unless I missed
something.
> >
> > Using a stylesheet?
> >
> > css = """QLineEdit {
> > background-color: red;
> > }"""
> > myWidget. setStyleSheet(css)
> >
> > I didn't test...
> >
> > http://doc.trolltech.com/4.4/stylesheet.html#overview
> > http://doc.trolltech.com/4.4/qwidget.html#styleSheet-prop
> >
http://doc.trolltech.com/4.4/stylesheet-examples.html#customizing-qlineedit
> >
> > --
> > Frédéric
> >
>
> Worked perfectly. I knew it had to be easy and I overlooked the answer!
> Thanks all.
> --
> Douglas E Knapp
>
> Amazon Gift Cards; let them choose!!
>
http://www.amazon.com/gp/product/B001078FFE?ie=UTF8&tag=seattlebujinkand&linkCode=as2&camp=1789&creative=9325&creativeASIN=B001078FFE
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
You can also do:
line_edit = QLineEdit()
palette = QPalette()
palette.setColor(widget.backgroundRole(), QColor('red'))
line_edit.setPalette(palette)
for a more subtle effect, you might consider exchanging backgroundRole()
with foregroundRole().
Mads
More information about the PyQt
mailing list