[PyQt] Re: Setting backgroud color to a QListViewItem

Hans-Peter Jansen hpj at urpla.net
Mon Apr 14 21:22:51 BST 2008


Am Montag, 14. April 2008 schrieb Christoph Burgmer:
> > Someone can send example code to set background color to a
> > QListViewItem (pyqt3)?
>
> defaultPalette = QtGui.QPalette(element)
> newPalette = QtGui.QPalette(defaultPalette)
> newPalette.setColor(QtGui.QPalette.Base, Qt.green)
> element.setPalette(newPalette)
>
> This at least works for QLineEdit under KDE4.

You need to reimplement the paintCell method in your QListViewItem subclass.

Pete


More information about the PyQt mailing list