[Qt-interest] Removing Qt Stylesheet from child dialog

Andre Somers andre at familiesomers.nl
Thu Jan 27 09:47:29 CET 2011


Op 26-1-2011 22:51, NoRulez schreef:
>> If you don't want something styled, make sure the styles selectors do not match. One way to do this is to use a property selector and set a corresponding, custom property on the dialogs that you want you style to apply to.
> Could you please give me a small example on how to do this?
Something along these lines should work:

On the dialogs that need to adhere to styling, do something like this:
myDialog->setProperty("cssStyling", true); //set a property to use as a 
selector

Then, formulate your CSS rules to match:

QDialog[cssStyling="true"] QPushButton { ... // the actual style }

This will make sure that only pushbuttons that decent somehow from a 
QDialog that has the cssStyling property set to true will be styled 
according to that rule. If you don't set the property for the dialogs 
you don't want the style to apply to, you have achieved your goal.

Note that Qt unfortunately does NOT update styling if you update such a 
property used as a CSS selector. So, set the property first, and the 
style later. Otherwise, you need to force a style recalculation.

André




More information about the Qt-interest-old mailing list