Clarification on Attached properties
-
Dear All,
in these days I'm studying QML more deeper and I have some questions about attached properties.
In reference doc I read that attached properties are not inheritated from attachee object's children, that's ok because, if I've understood correctly, attached property is an object that will be created at the instantion of the attachee object (which is pass to the attached property in factory method as follow:static AttachedPropertyType *qmlAttachedProperties(QObject *object) // AttachedPropertyType = attached property instance // QObject* = attachee Object
So, in doc A Note About Accessing Attached Properties and Signal Handlers ListView example, QObject* parent must be a ListView: is this the reason why Rectangle can't access to isCurrentItem property?
I mean, Rectangle can instance a Listview attached property, however it doesn't work because Rectangle parent is of Item type, and not a ListView type.Another question is about attach property application:
I see that on Material Theme, each Material Component has the attach property Material: it means that each component has to instance a Material property to work correcly. In this case, Material has some information such as colors, elevation and so on.
My question is: for theming, isn't easier to use SingleTon Class? Which are the benefit on using attached properties in this case?Thanks to all,
Nicola