Is Qt\'s dynamic properties really so dynamic with stylesheets?
I have the basic example from stylesheets and dynamic properties:
/*stylesheet:*/
*[f
I tried this too with no luck, and when I found the following text in the documentation, I gave up. See The Style Sheet Syntax:
Warning: If the value of the Qt property changes after the style sheet has been set, it might be necessary to force a style sheet recomputation. One way to achieve this is to unset the style sheet and set it again.
The following works for me to ensure a proper restyling of the widget:
myWidget->setStyle(QApplication::style())
Forcing a recomputation of the stylesheets as proposed by mdcl did not work for me. I am using Qt 4.5.3.
Qt has the following recommendation in their FAQ:
style()->unpolish(theWidget);
style()->polish(theWidget);
They also say you can reset the stylesheet by doing the following but it is more expensive:
setStyleSheet(styleSheet());
I found a quick, although a bit hackish, way to update widget's styling.
myWidget->style()->unpolish(myWidget);
myWidget->ensurePolished();
Doing this after changing properties keeps correlation between property data and UI.