Unsolved Access a property from one qml file to other qml file
-
Hi,
I am working on properties on qml. I am creating a property alias in one qml file, but I want to get that property behavior in other qml file. So, how can we get access to the property, is their is a procedure, if so how?
-
I think you want a property binding, not an alias?
property-aliases
property-attributesI'll try to show you both working together: below, an component with id: foo has declared a Bar instance with a binding to foo's fooInt property.
We don't know or really care if it's property or alias, just that we can and do bind to it.
id: foo; property int fooInt : 0; Bar { barInt : fooInt; }
If we take a look inside our Bar.qml - we are using an alias to expose externally only the features/properties we wish, like so:
Item { id: root; property alias barInt : barInternal.number; SomeOtherComponent { id: barInternal; property int number : 0; property color color : "red"; property string string : ""; } }
Now if I we go back and look at foo where the Bar instance is. We fully understand that is an property binding to Bar's aliased property. It still behaves exactly as a Bar property and you can control it as such.
Bar users only need to know Bar has an int property "barInt".
Bar { barInt : fooInt; }