qss - Using variables in qt StyleSheets -
is there possibility of giving variable name hex/rgb numbers in .qss file . eh
mycolor = #ffcc08 qpushbutton { background-color: mycolor;} so can define variable @ top of stylesheet , use variable name whereever required instead of using hex code. if need change color have change in 1 place , reflected throught file.
i searched saas don't know how can used in qt.
thanks :)
you build own tiny sass quite easily:
1.create text file definitions of variables. use simple format this:
@mycolor = #ffddee @mycolor2 = #112233 @mywidth = 20px 2.in qss file use variable names:
qpushbutton { background-color: @mycolor; min-width: @mywidth; } 3.open both files , each variable in definition file change occurrence in qss file value (string) definition file. simple string replacement.
4.apply preprocessed qss in app.
this simplest solution. can change both definition file , qss file outside app , apply without recompilation of code.
Comments
Post a Comment