As both myQml1, myQml2 are just readonly references to qml objects this will not work.
If you really would want to change ALL the properties of object you could achieve this via
onSomeSignal:{
copyProperties(myQml1, myQml2);
}
function copyProperties(source, target) {
var properties = Object.keys(source);
for (var i = 0, l = properties.length; i < l; ++i) {
var prop = properties[i];
var type = typeof target[prop];
if (type === "function" /* || add your own checks here */) {
return;
}
target[prop] = source[prop];
}
}
This does not check for properties that might not exist on the target or properties that you might not want to change (like objectName or parent) or readonly properties that you might have on those objects, so please adapt to your usecase ;)
Or in the best case – do it some other way, as proposed before.
↧