Using two stylesheets for the same widget
-
@ivanicy said in Using two stylesheets for the same widget:
some condition
What condition would it be?
If you build different versions of your software you can decide at compile time what to use.
You you check the condition at runtime and load the stylesheet accordingly. -
-
You can use custom properties set in your widgets to decide what stylesheet to apply:
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-using-dynamic-properties -
Hi,
Since you have your stylesheet in a file, use a placeholder for the colour and before your set the stylesheet replace the placeholder with the value matching what you want.
-
@ivanicy
I do just what @SGaist has just suggested.I don't like to maintain multiple files for different configurations, too much work. So to have stylesheets vary just by, say, color, I write one external stylesheet like
class1 { color: ##COLOR1##; } widget2 { background-color: ##COLOR2##; }
in as many places as necessary. Then because you have to read the stylesheet in via code to apply it anyway, it's simple to substitute the various
##...##
sequences for whatever you need while you're doing so.