[SOLVED] CSS change property from SLOT not working
-
Solved doing a first setProperty in the other method then it works in the slot!
-
Hi,
Since it's a static style sheet, why don't you apply it directly in the constructor ?
-
bq. This is where I set my CSS (in the constructor):
bq. this->setStyleSheet("QWidget{background:rgba(246,246,246,246);}"
bq. ......As I said, I set the style sheet in the constructor while at runtime I set the correct "state" property. It works but I need to set the property twice in order to see it applied like:
@ ui.slider1->setProperty("state", true);
ui.slider1->setProperty("state", true);@
-
Sorry, I missed the parenthesis about the constructor.
Do you initialize the state property ?
-
How should I initialize it?
-
That's up to you know what is a sensible default value. Probably false ?
-
Oh sure! I didn't understand what you meant!
Yes I am initializing it in an init() method called by the constructor!@ui.slider1->setProperty("state", false);@
-
I thought I was forgetting something… "Here":http://qt-project.org/wiki/DynamicPropertiesAndStylesheets you have the technique
-
Well, I solved the problem. I was using that post to learn how to do it but I wasn't doing this:
@tstFrame->setProperty("error",true);
tstFrame->style()->unpolish(tstFrame);
tstFrame->style()->polish(tstFrame);
tstFrame->update();@because when I started this thread I tried that piece of code but I had many errors (I don't remember which ones) and I thought it was for older versions of QT :(
Thanks :D
-
You're welcome !
Since you have your stilling in place now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)