blob: 063a4a66b72e2b4989057735fc1d32988edbe248 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import QtQuick 1.0
import Qt.labs.WebChannel 1.0
import QtWebKit 1.0
Rectangle {
width: 1000
height: 360
WebChannel {
id: webChannel
onExecute: {
var data = JSON.parse(requestData);
txt.text = data.a;
response.send(JSON.stringify({b:'This is a response from QML'}));
}
onBaseUrlChanged: {
console.log(baseUrl);
}
}
WebView {
id: webView
url: "index.html?webChannelBaseUrl=" + webChannel.baseUrl ;
settings.developerExtrasEnabled: true
anchors.top: txt.bottom
height: 200
width: 200
}
TextEdit {
width: 1000
height: 100
id: editor
anchors.top: parent.top
}
Text {
id: txt
text: "Click"
anchors.top: editor.bottom
MouseArea {
anchors.fill: parent
onClicked: {
webChannel.broadcast("incoming-call", JSON.stringify(editor.text));
}
}
}
}
|