tags:

views:

58

answers:

1

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

http://curiouschap.com/wp-content/uploads/2010/05/stack_qcombobox_question.png [as a newbie, SO wouldn't let me insert the image]

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?

+3  A: 

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.

Leiaz
Agreed. Instead of using generics in your stylesheet, make it specific to only the QWidgets you want to style.
Brian Roach
Thank you, this was very helpful. It seems that using the following specific selector syntax QWidget#my_container_name *will* indeed keep the style local to the QWidget whose name is my_container_name and prevents it from cascading.
Hisham Abboud