[PyQt] set qlineedit red, easy??

Matt Smith melkor at orangepalantir.org
Thu Feb 5 12:50:57 GMT 2009


You could use the palette.


MyLineEdit.palette().setColor(QtGui.QPalette.Base,QtGui.QColor('red'))

mbs

On Thu, 2009-02-05 at 12:00 +0000, pyqt-request at riverbankcomputing.com 
> 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...



More information about the PyQt mailing list