I have a string id
of an object I need to find in QML tree.
For example:
var idToFind = "myBtnId"
Can I do something like the following?
var objectThatINeed = myMainWindow.findObjectById(idToFind)
As far as I understand I can use objectName
for this purpose (at least from C++). Can I still reuse existing id
s somehow without introducing the names?
I want to use this object as a parent for some other dynamically created controls.
No, you have to use
objectName
or some other property.The id Attribute:
If you know the IDs of all items you want beforehand, you can create an object map for them and use that to look them up. For example: