I am setting the background color of a QWidget subclass. When I do this using a stylesheet, the styles of the other components in the QWidget change (eg, the color of a PushButton, and its look changes).
How do I make sure only the background color of the container widget changes and the rest of the child components remain unchanged?
One way is to specify an ID selector. Make sure to set the
objectNameof your container widget (withsetObjectName()) and use that name in the CSS selector. Assuming a widget namedMyContainer, you would use something like this: