QCss::Parser -- how to reproduce behavior?
-
The QCss::Parser class could be incredibly useful for the average Qt user if they want to test the sanity of stylesheets themselves.
This could be in a situation where the program's stylesheets are user-definable, and they want to spare the application of having an erroneous style applied to it, even though the program will still run. I know that the invalid selectors will not be applied to, but I want this to be recognizable on the basis in which I'm setting the stylesheet.Judging by the fact that the actual code for this is not provided, and only acknowledgable through the includes, I've assumed behavior is different depending on the platform/version of Qt. Why is this?
More importantly, how can I reproduce this behavior without adding
gui-private
and jeopardizing my stability and ability to run on differing modules (not to mention the errors)? Is there an underlying class/framework that this parser uses? I'm talking specifically about theQCss::Parser::parse()
method. -
Hi
The parser seems handwritten.https://code.woboq.org/qt5/qtbase/src/gui/text/qcssparser_p.h.html
https://code.woboq.org/qt5/qtbase/src/gui/text/qcssparser.cpp.html
-
I did end up looking at the source file between now and when I posted initially.
I see how they did the parsing, and it isn't very flexible for re-implementation. Seeing as how it already exists in the source, and is undeniably being used somewhere down the line when stylesheets are used, I just think it's so ridiculous they don't allow public access to this method or something similar. Even if it were the easiest thing to re-implement, doing so is not my favorite idea if the code is already "available" to me (so to speak).Do you know of anyone who has faced this issue & the solution they came up with?
-
I did end up looking at the source file between now and when I posted initially.
I see how they did the parsing, and it isn't very flexible for re-implementation. Seeing as how it already exists in the source, and is undeniably being used somewhere down the line when stylesheets are used, I just think it's so ridiculous they don't allow public access to this method or something similar. Even if it were the easiest thing to re-implement, doing so is not my favorite idea if the code is already "available" to me (so to speak).Do you know of anyone who has faced this issue & the solution they came up with?
@Ewan-Green
Hi
well the use of _p private headers is to keep as much as possible as
implementation details as Qt promise backward compatibility so
they are careful what makes it to public interfaces.If they allowed access to parse it would have to return its internal data structures
and hence it would have become public.
However, I agree. They could at least return parse status with err number and line
if it had errors.It has been asked on forums a few times and solutions range from copy the parser files and make own version to using external lib like http://www.netsurf-browser.org/projects/libcss/
-
Thank you.