I would like to set up the following object hierarchy:
Foo has children of type Child named Child1 and Child2. The Child type has fixed properties : prop1 and prop 2 for example. I can see how to create this object hierarchy in C++ using the Q_PROPERTY syntax and then push then into the QML context such that I can property bind to Foo.Child1.prop1. The problem I am trying to solve is that the number of Child objects and their names is determined at runtime. I don't see how I can create a Foo object that exposes a dynamic set of Child objects that still supports property binding.
Docs for Qt Script seems to say that if I parent the child QObjects to Foo and give them names I should be able to access them that way. But that seems to be only for Qt Script. I can't get it to work in QML.
QScriptValue looked promising as well. Since you can create the object dynamically and add properties to it. But once again that seems to be only for Qt Script.
Is there some other way to do it?
Bookmarks