Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Qt's stylesheets really handling _dynamic_ properties?

Tags:

stylesheet

qt

Is Qt's dynamic properties really so dynamic with stylesheets?

I have the basic example from stylesheets and dynamic properties:

/*stylesheet:*/
*[field_mandatory="true"] { background-color: "yellow";}

And I have this happening at runtime somewhere in the code:

/*code:*/
myWidget->setProperty("field_mandatory", field->isFilled() );

Nothing changes in UI, when this property is changed at runtime.

Does anyone have ideas what must be done to update Qt's stylesheet engine when changing properties, or is it even capable handling these kinds of cases?

Btw. I'm using Qt 4.4

like image 810
mdcl Avatar asked Oct 20 '09 15:10

mdcl


People also ask

Does Qt Designer use CSS?

Qt allows you to decorate your Graphical User Interfaces (GUIs) using a style sheet language called Qt Style Sheets, which is very similar to Cascading Style Sheets (CSS) used by web designers to decorate their websites.


1 Answers

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());
like image 76
Jason Avatar answered Sep 28 '22 07:09

Jason