Reading CSS property from C++ code
-
As the title suggests, I would like to know if it is possible to read CSS properties or attributes from my C ++ code.Thanks for your tips!
For (abstract) example:
QVariant getValue(QWidget* widget, const QString& propertyName) { return widget->style()->getValue(propertyName); }
-
Hi
You would have to parse the stylesheet yourself.
There is no API for it. sadly.
You could look at Qt source for its cssparser or
be inspired from
https://www.codeproject.com/Articles/20450/Simple-CSS-Parser -
There's plenty of libraries available that can parse CSS, for example: https://github.com/lexborisov/mycss
-
Ok, but there is not any Qt's own functionality to do that? I know, I can parse the styleSheet, but when Qt were able to giving me what I'm searching for, it could be surly the better way to solve this problem (...I think)
-
@peter-70
That's why the answers are saying that there is not such an inbuilt Qt API for this....@JonB said in Reading CSS property from C++ code:
there is not such an inbuilt Qt API for this
Irrelevant note: there is (it's the one Qt uses to read style sheets applied to widgets) but it's not exposed to the external users, it's private to the libraries
-
@JonB said in Reading CSS property from C++ code:
there is not such an inbuilt Qt API for this
Irrelevant note: there is (it's the one Qt uses to read style sheets applied to widgets) but it's not exposed to the external users, it's private to the libraries