udp模式功能实现
parent
916c23a1ec
commit
b2cab52f89
|
@ -3,21 +3,18 @@ import QtQuick.Controls 2.14
|
|||
import QtQuick.Layouts 1.0
|
||||
import QtQml 2.3
|
||||
|
||||
|
||||
|
||||
Item {
|
||||
objectName: "NetSelect"
|
||||
width: 800
|
||||
height: 600
|
||||
visible: true
|
||||
|
||||
|
||||
|
||||
ColorAnimation {
|
||||
from: "white"
|
||||
to: "black"
|
||||
duration: 200
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
color: "#aeaeae"
|
||||
anchors.rightMargin: 0
|
||||
|
@ -109,7 +106,6 @@ Item {
|
|||
"tcp"
|
||||
]
|
||||
}
|
||||
|
||||
RadioButton {
|
||||
id: radioSelectWebsocket
|
||||
Layout.leftMargin: 20
|
||||
|
@ -145,7 +141,6 @@ Item {
|
|||
wrapMode: Text.NoWrap
|
||||
font.pointSize: 20
|
||||
}
|
||||
|
||||
TextEdit {
|
||||
id: hostEdit
|
||||
Layout.leftMargin: 20
|
||||
|
@ -175,29 +170,36 @@ Item {
|
|||
|
||||
onClicked: {
|
||||
if(button_network.text == "打开网络"){
|
||||
console.log(proto_combox.currentText)
|
||||
let type_network = -1
|
||||
if(proto_combox.currentText == "udp" ){
|
||||
if(proto_combox.currentText === "udp" ){
|
||||
type_network = 0
|
||||
button_network.text = "关闭连接"
|
||||
|
||||
}
|
||||
if(proto_combox.currentText == "tcp" && (conn_type.currentText == "server")){
|
||||
if(proto_combox.currentText === "tcp" && (conn_type.currentText === "server")){
|
||||
type_network = 1
|
||||
button_network.text = "正在连接"
|
||||
}
|
||||
if(proto_combox.currentText == "tcp" && (conn_type.currentText == "client")){
|
||||
if(proto_combox.currentText === "tcp" && (conn_type.currentText === "client")){
|
||||
type_network = 3
|
||||
button_network.text = "正在连接"
|
||||
}
|
||||
|
||||
console.log(hostEdit.text,
|
||||
port.text,
|
||||
radioSelectWebsocket.checked,
|
||||
type_network)
|
||||
|
||||
let ret = DataWrap.openNetwork(hostEdit.text,
|
||||
Number(port.text),
|
||||
radioSelectWebsocket.checked,
|
||||
type_network)
|
||||
|
||||
button_network.text = "正在连接"
|
||||
|
||||
}else (button_network.text == "关闭连接")
|
||||
}else if ((button_network.text === "关闭连接") && (proto_combox.currentText !== "udp"))
|
||||
{
|
||||
console.log("dfdfads")
|
||||
DataWrap.closeNetwork();
|
||||
button_network.text = "打开网络"
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ int QmlShareData::openNetwork(QString ip, unsigned int port, bool is_ws,int type
|
|||
(type == NetworkController::TYPE_UDP_SERVER)){
|
||||
m_network_ = new NetworkController((NetworkController::NetworkType)type,ip,port);
|
||||
connect(m_network_,SIGNAL(on_data_recv()),this,SLOT(on_network_data_recv()));
|
||||
emit(sendToQml(11));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue