Different stylesheets in the same window
-
Hello!
I am trying to use two differents stylesheets for the same window. I have a DEFINES variable in .pro file that I use to choose and load the correct file. My method is:
- I fill the window stylesheet from the Qt designer (rightclicking the dialog and pressing change stylesheet option).
- When I get the desired style, I copy all to a file that I save in the resources.
- Using the DEFINES variable, I choose which file I want to load in the .cpp
The problem is, sometimes and some widgets don't change their stylesheet because I have another stylesheet (made in step 1).
How can I remove this first stylesheet with code? Because I need it in the designer for viewing the stylesheet result.
Thank you very much!
-
Hi
If you assign the stylesheet to the top widget ( like the dialog)
it should replace the old stylesheet if you load
another styleSheet and apply to the same to object.However, you might need to ask Dialog to redraw itself via
update()if its still not refreshed, you can try
style()->unpolish(this);
style()->polish(this);