Reading CSS property from C++ code
-
wrote on 25 Jan 2019, 07:14 last edited by peter-70
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 -
wrote on 25 Jan 2019, 08:40 last edited by
There's plenty of libraries available that can parse CSS, for example: https://github.com/lexborisov/mycss
-
wrote on 25 Jan 2019, 09:00 last edited by
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)
-
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....wrote on 25 Jan 2019, 10:04 last edited by@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
wrote on 25 Jan 2019, 10:16 last edited by JonB
1/7