[PyQt] Failure setting QListView background color

Damon Lynch damonlynch at gmail.com
Tue Mar 10 19:17:11 GMT 2015


Hello all,

What am I doing wrong below? If I comment out the setStyleSheet call , 
and enable the palette changes, the background remains the default 
white. The problem with using the setStyleSheet call is that it affects 
the scrollbars inside the QListView too, which is not what I want.

class ThumbnailView(QListView):
     def __init__(self):
         super(ThumbnailView, self).__init__(uniformItemSizes=True, 
spacing=16)
         self.setViewMode(QListView.IconMode)
         # this next line works
         self.setStyleSheet("background-color:#444444")
         # these next three lines do not work when the lines are 
uncommented:
         # palette = self.palette()
         # palette.setColor(self.backgroundRole(), QColor(68,68,68))
         # self.setPalette(palette)

Best,
Damon

-- 

http://www.damonlynch.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150311/ade4a229/attachment.html>


More information about the PyQt mailing list