I have a custom object in QML which uses a Loader to dynamicly loads qml objects and sets properties of it. I want to access all the properties of the ListElement, and pass it trough to the Loader.
model: ListModel {
ListElement {
bodySource: "some_object.qml"
bodyModel: ListElement {
myProp1: false
myProp2: ""
myProp3: 0.0
}
}
}
var bodyModelElement = model.get(0).bodyModel.get(0);
for (var propertyName in bodyModelElement)
{
console.info("propertyName: " + propertyName);
}
The propblem with this is that I get also a lot of other property names I didn't expect.
qml: propertyName: objectName
qml: propertyName: myProp3
qml: propertyName: myProp2
qml: propertyName: myProp1
qml: propertyName: objectNameChanged
qml: propertyName: __0
qml: propertyName: __1
qml: propertyName: __2
Where __0
, __1
, __2
and objectNameChanged
is of type object
and objectName
is an empty string
How can I only get myProp1
, myProp2
and myProp3
?
Or should I just exclude the names starting with an underscore and objectName(Changed)
if(bodyModelElement.hasOwnProperty(propertyName))
can help to filter to undesired properties out. – skypjack