Styling/theming QML in a CSS-like way
I know that QML does not support CSS styling like widgets do, and I have read up on different alternative approaches to styling/theming:
Common for these approaches is that they require the developer to specify the parts of the QML that can be styled, either by binding to a property in a “styling QML file/singleton”, or by using a Loader to load a different QML component based on style name. What I would like is something that works like the "id" selector in CSS instead of the "class" selector, so that the individual QML files do not have to know whether they will be styled later on or not.
My current approach make all the QML files look similar to this (using approach in link 2):
//g_theme is defined in root context and loaded dynamically
What I would like to do is:
color: “green” // default color
And then have a styling file that defines (or similar)
@Main.qml #background: red@
Is this possible at the moment, or something that is in the pipeline for a future Qt version, or will the preferred way of styling continue to be something similar to the approach described in the links above?
SGaist Lifetime Qt Champion last edited by
Hi and welcome to devnet,
Interesting question and proposition, however, I would recommend to post them on the interest mailing list. You'll find there Qt's developers/maintainers. This forum is more user oriented