Qt – How to make a Qt widget ignore style sheets set on parent widgets

qt

When adding a QComboBox control in Qt Designer, I get a terrible looking, non-native control:

enter image description here

On digging further, it turns out that two of the parent controls, QParentWindow and QStackedWidget, have style sheets that QComboBox is inheriting. If I delete the custom styles, then I get a native QComboBox like the one on the left.

How can I have QComboBox (and widgets generally) NOT inherit parent styles? Or, how can I create a style for, say, QParentWindow, and do it so that it's local only and does not cascade?

Best Answer

I don't think you can prevent it from cascading. But by using more specific selectors in your stylesheet, maybe you could define properties only for your QParentWindow class or specific object.

Related Topic