-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
58 lines (50 loc) · 1.31 KB
/
main.qml
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
49
50
51
52
53
54
55
56
57
58
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.0
import org.raymii.NetworkExample 1.0
Window {
id: root
width: 400
height: 300
visible: true
title: qsTr("Network Example by Raymii.org")
property var response: undefined
function doGetRequest(url) {
var xmlhttp = new XMLHttpRequest()
xmlhttp. () {
if (xmlhttp.readyState === XMLHttpRequest.DONE
&& xmlhttp.status == 200) {
response = xmlhttp.responseText
}
}
xmlhttp.open("GET", url, true)
xmlhttp.send()
}
Column {
spacing: 5
anchors.fill: parent
anchors.margins: 5
Row {
spacing: 5
Button {
text: "Qml HTTP GET"
onClicked: doGetRequest("http://httpbin.org/ip")
}
TextField {
id: qmlResult
text: response
}
}
Row {
spacing: 5
Button {
text: "C++ HTTP GET "
onClicked: NetworkExample.doGetRequest("http://httpbin.org/ip")
}
TextField {
id: cppResult
text: NetworkExample.response
}
}
}
}