summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/qml/example.qml10
-rw-r--r--examples/qml/index.html3
-rw-r--r--examples/standalone/main.cpp9
3 files changed, 14 insertions, 8 deletions
diff --git a/examples/qml/example.qml b/examples/qml/example.qml
index f77b4c6..2d51f27 100644
--- a/examples/qml/example.qml
+++ b/examples/qml/example.qml
@@ -58,8 +58,11 @@ ApplicationWindow {
WebChannel {
id: webChannel
- onRawMessageReceived: {
- textEdit.text += "Received message: " + rawMessage + "\n";
+ connections: WebViewTransport {
+ webViewExperimental: webView.experimental
+ onMessageReceived: {
+ textEdit.text += "Received message: " + message + "\n";
+ }
}
}
@@ -106,8 +109,9 @@ ApplicationWindow {
Layout.fillHeight: true
Layout.minimumWidth: window.width / 2
id: webView
- url: webChannel.baseUrl ? ("index.html?webChannelBaseUrl=" + webChannel.baseUrl) : "about:blank"
+ url: "index.html"
experimental.preferences.developerExtrasEnabled: true
+ experimental.preferences.navigatorQtObjectEnabled: true
}
}
}
diff --git a/examples/qml/index.html b/examples/qml/index.html
index cd20ac9..8b65dd2 100644
--- a/examples/qml/index.html
+++ b/examples/qml/index.html
@@ -5,8 +5,7 @@
<script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script>
<script type="text/javascript">
//BEGIN SETUP
- var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]);
- new QWebChannel(baseUrl, function(channel) {
+ new QWebChannel(navigator.qt, function(channel) {
document.getElementById("send").onclick = function() {
var input = document.getElementById("input");
var text = input.value;
diff --git a/examples/standalone/main.cpp b/examples/standalone/main.cpp
index 8546a12..836d324 100644
--- a/examples/standalone/main.cpp
+++ b/examples/standalone/main.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qwebchannel.h"
+#include "qwebsockettransport.h"
#include <QApplication>
#include <QDialog>
@@ -55,14 +56,14 @@ class Dialog : public QObject
Q_OBJECT
public:
- explicit Dialog(QWebChannel *channel, QObject *parent = 0)
+ explicit Dialog(QWebSocketTransport *transport, QObject *parent = 0)
: QObject(parent)
{
ui.setupUi(&dialog);
dialog.show();
connect(ui.send, SIGNAL(clicked()), SLOT(clicked()));
- connect(channel, SIGNAL(baseUrlChanged(QString)),
+ connect(transport, SIGNAL(baseUrlChanged(QString)),
SLOT(baseUrlChanged(QString)));
}
@@ -109,8 +110,10 @@ int main(int argc, char** argv)
QApplication app(argc, argv);
QWebChannel channel;
+ QWebSocketTransport transport;
+ channel.connectTo(&transport);
- Dialog dialog(&channel);
+ Dialog dialog(&transport);
channel.registerObject(QStringLiteral("dialog"), &dialog);