summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2013-01-17 17:21:41 +0100
committerZeno Albisser <zeno.albisser@digia.com>2013-11-01 09:39:51 +0100
commit66d625c54b659a39d25916da66849c23b56e714a (patch)
tree47c0e19f9fe7feaf3852a3c763ccf19ebe23e405 /examples
parentd1eeac733c47e106af2aeb34cf24beb36a1c60fe (diff)
downloadqtwebchannel-66d625c54b659a39d25916da66849c23b56e714a.tar.gz
Fix iteration over objects - they do not have .forEach nor .length.
Change-Id: Idedb73408b2ee4fb8653ba5b74bf30aa503df779 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/qtobject/qml/qtobject/qtobject.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/examples/qtobject/qml/qtobject/qtobject.js b/examples/qtobject/qml/qtobject/qtobject.js
index f0fe370..0553a36 100644
--- a/examples/qtobject/qml/qtobject/qtobject.js
+++ b/examples/qtobject/qml/qtobject/qtobject.js
@@ -63,9 +63,9 @@ window.onload = function() {
var object = {};
var objectName = addObjectData.name;
var data = addObjectData.data;
- for (var i = 0; i < data.methods.length; ++i)
+ for (var i in data.methods)
methodsAndSignals.push(data.methods[i]);
- for (i = 0; i < data.signals.length; ++i)
+ for (i in data.signals)
methodsAndSignals.push(data.signals[i]);
methodsAndSignals.forEach(function(method) {
@@ -86,16 +86,18 @@ window.onload = function() {
};
});
- data.signals.forEach(function(signal) {
+ for (i in data.signals) {
+ var signal = data.signals[i];
object[signal].connect = function(callback) {
objectSignals[signal] = objectSignals[signal] || [];
webChannel.exec(JSON.stringify({type: "Qt.connectToSignal", object: objectName, signal: signal}));
objectSignals[signal].push(callback);
};
- });
- allSignals[addObjectData.name] = objectSignals;
+ }
+ allSignals[objectName] = objectSignals;
- data.properties.forEach(function(prop) {
+ for (i in data.properties) {
+ var prop = data.properties[i];
object.__defineSetter__(prop, function(value) {
webChannel.exec(JSON.stringify({type: "Qt.setProperty", object: objectName, property: prop, value: value }));
});
@@ -106,9 +108,9 @@ window.onload = function() {
});
});
});
- });
+ }
- window[addObjectData.name] = object;
+ window[objectName] = object;
}
);
webChannel.exec(JSON.stringify({type:"Qt.getObjects"}));