How to declare variables in Qt Stylesheets
Hi all,
Anybody knows if it is possible to create variables in a Qt Stylesheet (.qss)?
For instance, I know CSS accepts the following:
Code:
@variables {
myColour: #fe8d12;
}
div {
background-color: var(myColour);
}
I tried the same in qt (with QWidget instead of div) with no avail.
Any suggestions?
If it is not possible it would be a nice feature request.
Re: How to declare variables in Qt Stylesheets
I want know to, how i can declare variables in Qt Stylesheets. So it's impossible ?
Re: How to declare variables in Qt Stylesheets
... another zombie thread.
That ability is certainly not in the Qt Style Sheets docs. If you've tried it and it doesn't work then it doesn't work. You can, of course, dynamically create style sheets:
Code:
"QLabel { background-color: %1; color: %2; }"
"QLineEdit { background-color: %1; }"
);
...
setStyleSheet( styleSheet.arg(varBGColour).arg(varFGColour) );
I'd make sure it cannot be done with inheritance first.
Re: How to declare variables in Qt Stylesheets
Yes, i know that i can dynamically create style sheets. But more better when you edit style sheet in designer, (not from code).