diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2014-01-09 17:21:39 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-10 13:09:03 +0100 |
commit | 625c881cc74f2552e211b9ba81ac3b0ed30e9947 (patch) | |
tree | 246cf6d749138448423bf6b4da17a0306f8c1e0a /examples | |
parent | b23442674f1b30d936fca43aee7b7d6dece15b2c (diff) | |
download | qtwebchannel-625c881cc74f2552e211b9ba81ac3b0ed30e9947.tar.gz |
Add declarative object-registration API to QML WebChannel.
The new registeredObjects list property is now preferred over the old
imparative registerObject/registerObjects API.
Items that are added to the list need an attached WebChannel.id property
which holds the identifier under which the object is published to remote
clients.
Change-Id: I96a8047b9a85e27f3fd48c900180c22ebd20eb35
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/qtobject/main.qml | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/examples/qtobject/main.qml b/examples/qtobject/main.qml index 7bfe714..d8ec54b 100644 --- a/examples/qtobject/main.qml +++ b/examples/qtobject/main.qml @@ -49,23 +49,21 @@ import QtWebKit.experimental 1.0 Rectangle { TestObjectFactory { id: factory + WebChannel.id: "testObjectFactory" } TestObject { id: testObject objectName: "initialTestObject" + WebChannel.id: objectName } WebChannel { id: webChannel - onInitialized: { - registerObjects({ - "testObjectFactory": factory, - "initialTestObject": testObject - }); - - webView.url = "qrc:/index.html?webChannelBaseUrl=" + webChannel.baseUrl; - } + registeredObjects: [ + factory, + testObject + ]; } width: 480 @@ -73,7 +71,7 @@ Rectangle { WebView { id: webView - url: "about:blank" + url: webChannel.baseUrl ? ("qrc:/index.html?webChannelBaseUrl=" + webChannel.baseUrl) : "about:blank"; anchors.fill: parent experimental.preferences.developerExtrasEnabled: true } |