-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chat.qml
63 lines (55 loc) · 1.03 KB
/
Chat.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
59
60
61
62
63
import QtQuick 2.0
import QtQuick.Controls 1.0
import Ros 1.0
Rectangle {
id: chat
width: 320; height: 320
color: "lightgray"
Ros {
id: ros
Publisher {
id: pub
queueSize: 10
topic: Topic {
name: 'chatter'
type: 'std_msgs/String'
}
}
Subscriber {
id: sub
queueSize: 1
topic: Topic {
name: 'chatter'
type: 'std_msgs/String'
}
onMessageChanged: {
display.text += msg.data + '\n'
}
}
}
Item {
id: input
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 20
TextField {
id: textField
anchors.right: send.left
anchors.top: input.top
placeholderText: 'Enter'
}
Button {
id: send
anchors.top: input.top
text: 'Send'
y: 30
onClicked: pub.publish({'data': textField.text})
}
}
Text {
id: display
anchors.top: input.bottom
anchors.topMargin: 50
anchors.leftMargin: 10
}
}