Component property/variable declaration with children range of validy
-
Hey,
i am declarating variables using property. When i declare them in my top-level component the range is global, but when i am declaring them in a children of my top-level component, the range doesnt affect the children, is it possible to create some sort of variable which the children can access like a global variable?
-
See http://qt-project.org/doc/qt-5.0/qtqml/qtqml-documents-scope.html#component-scope and http://qt-project.org/doc/qt-5.0/qtquick/qtquick-performance.html#bindings for information about evaluation scope.
If you want children to be able to access a property, you can declare that property in the root object in the component scope, or as a context property.
Alternatively, use a Singleton (clearer since you have to prefix usages with the typename, and more optimizable in general).
Cheers,
Chris. -
Hello,
thanks for your reply. I'll give it a look.