调整布局

master
zcy 2021-05-04 00:05:38 +08:00
parent a28c997ac8
commit fa170df052
5 changed files with 26 additions and 9 deletions

View File

@ -4,12 +4,20 @@ import QtQuick.Layouts 1.0
Item {
id: serial_select_view
objectName: "SerialSelect"
width: parent.width - 80
height: parent.height
property var comlist: []
visible: true
property bool uart_open: false
signal notify(string message)
Component.onCompleted: {
//slot signal.connect(id.slot)
console.log(parent)
notify.connect(root.on_notify)
}
ColorAnimation {
from: "white"
@ -193,12 +201,14 @@ Item {
if(ret == 0){
uart_open = true
button.text = "关闭串口"
serial_select_view.notify("串口已经连接")
}
}else{
let ret = DataWrap.closeSerial();
if(ret == 0){
button.text = "打开串口"
uart_open = false
serial_select_view.notify("串口已经关闭")
}
}
}

View File

@ -11,13 +11,17 @@ Rectangle {
height: 900
visible: true
function on_notify(str){
status.text = str;
}
Flow{
anchors.fill: parent
width: parent.width
height: parent.height
Rectangle {
width: 80;
width: 100;
height: parent.height
color: "black"
Flow{
@ -73,7 +77,6 @@ Rectangle {
color: "white"
font.pointSize: 10
anchors.top: button_net.bottom
}
Button{
id: button_proto
@ -102,30 +105,33 @@ Rectangle {
}
Text {
id: status
text: qsTr("未连接")
width: parent.width
color: "white"
font.pointSize: 10
font.pointSize: 9
anchors.bottom: parent.bottom
Layout.leftMargin: 10
Layout.bottomMargin: 10
}
}
}
SerialSelect{
id: uart_choose
width: parent.width - 80
width: parent.width - 100
height: parent.height
}
NetSelect{
id: net_choose
width: parent.width - 80
width: parent.width - 100
height: parent.height
}
ProtoDebug{
id: proto_debug
width: parent.width - 80
width: parent.width - 100
height: parent.height
visible: false
}

View File

@ -63,9 +63,10 @@ int SerialController::SetListener(SerialController::SerialListener *p)
mListener = p;
}
int SerialController::SendData(uint8_t *data, uint8_t len)
int SerialController::SendData(char *data, uint8_t len)
{
if(mConnected){
qDebug()<<data<<len;
return mCurrentPort->write((char *)data,len);
}
return ERROR_SEND;

View File

@ -44,7 +44,7 @@ public:
int SetProto(QSerialProto *);
int SetListener(SerialListener *);
int SendData(uint8_t *,uint8_t len);
int SendData(char *,uint8_t len);
void GetSetting(QString baudRate, QString dataBits, QString stopBits, QString flow);
signals:
private:

View File

@ -63,7 +63,7 @@ int ShareData::ShowDataInQML(QString x)
int ShareData::SendUartData(const char *data)
{
if(nullptr != data){
this->m_serial_controller_->SendData((uint8_t *)data,strlen(data));
this->m_serial_controller_->SendData((char *)data,strlen(data));
return 0;
}
return -1;