1
votes

So, first off, I've already read this, and everything I can find online says the same thing. To restrict the scope of a stylesheet setting do this:

self.setObjectName( self._TAG )
self.setStyleSheet( "#{} {{ background-color:{}; }}".format( self._TAG, "#d5d5d5" ) )

Where self is an object derived from QFrame. The problem is that, at least in the case of objects derived from QFrame, it only excludes children that don't descend from QFrame. The buttons and checkboxes retain the default color, but the QLabels inherit from the parent.

So is there any way around this, other than explicitly specifying the stylesheet for each child?

1
I think you have to set the fill background attribute of your QLabel like this: setAutoFillBackground(True), for this to work. Otherwise, it will be transparent and display the background of the parent.Jean-Sébastien
That did it. You should make this an answer, so I can check it off. Thanks.orodbhen

1 Answers

1
votes

You have to set the autoFillBackground property of the Qlabel to True, otherwise, the label won't paint its background:

myqlabel.setAutoFillBackground(True)