Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limiting the effects of a stylesheet to the parent widget?

Tags:

css

stylesheet

qt

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?

like image 315
saurabhsood91 Avatar asked Jun 21 '12 20:06

saurabhsood91


1 Answers

One way is to specify an ID selector. Make sure to set the objectName of your container widget (with setObjectName()) and use that name in the CSS selector. Assuming a widget named MyContainer, you would use something like this:

QWidget#MyContainer {...}
like image 139
Arnold Spence Avatar answered Oct 18 '22 09:10

Arnold Spence