Obtain inherited stylesheet for a QWidget from parents above it

725 views Asked by At

Is there a simple way to obtain inherited stylesheet for a widget, if stylesheets were set in its parents (some levels above)? stylesheet() would return local value of property only.

In theory, to obtain text of effective stylesheet, I have to walk up to the topmost parent, then concatenate found styles, in order of parenthood. I was wondering if there is simpler way, library ALREADY does same thing. Problem is that concatenation doesn't work right with local stylesheets that do not have a selector in them

QWidget::styleSheet() call would return only the text for particular widget if set. Stylesheet is result of syntax parsing of that text, do I need to create my own parser of style sheet, that have to recreate way , how Qt work?

1

There are 1 answers

0
Swift - Friday Pie On BEST ANSWER

The solution indeed is either to create a parser and a generator, or use so an external source to generate style sheets. I ended up with an xml parser which was creating style sheet definitions for all widgets from a single configuration file, which was simpler to do and less error-prone.