Setting QList properties in qss files
-
I have a widget with custom Q_PROPERTYs defined that I'd like to modify in a .qss file. Most are pretty simple/straightforward (doubles or QColors), and can be modified virtually identically to this example. But I'd like to implement one property as a list of QColors, and modify it in the .qss file. Defining the Q_PROPERTY and registering it with the meta-object system isn't a problem, but I haven't found a way to set the property in the stylesheet. Has anyone else wrestled with this problem?
-
Hi and welcome to devnet,
I haven't tried that yet but I'm curious about what you already tried.
-
@SGaist Thanks!
I can successfully set the list property using
QObject::setProperty(...)
but can't seem to find a way to set the same property from the .qss file. I would imagine it has something to do with how the stylesheet is parsed? -
@mongrelmac said:
I would imagine it has something to do with how the stylesheet is parsed?
exactly. Qt stylesheets don't support parsing of list types.
The only thing you can do is, to declare the property as string and parse the string to your list in the setter of the property. -
I see. Thanks @raven-worx @SGaist!