Question

I wonder if there is a way to customize QListWidget background color.

I have tried:

listWidget=QtGui.QListWidget()
listWidget.setAutoFillBackground(True)
p = listWidget.palette()
p.setColor(listWidget.backgroundRole(), QtGui.QColor("#424242"))
listWidget.setPalette(p)

While there were no errors it still doesn't work.

Was it helpful?

Solution

You can set a stylesheet that changes the background:

self.setStyleSheet( """QListWidget{
                    background: yellow;
                }
                """
)

Example output:

SS

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top