调整布局

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 { Item {
id: serial_select_view
objectName: "SerialSelect" objectName: "SerialSelect"
width: parent.width - 80 width: parent.width - 80
height: parent.height height: parent.height
property var comlist: [] property var comlist: []
visible: true visible: true
property bool uart_open: false 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 { ColorAnimation {
from: "white" from: "white"
@ -193,12 +201,14 @@ Item {
if(ret == 0){ if(ret == 0){
uart_open = true uart_open = true
button.text = "关闭串口" button.text = "关闭串口"
serial_select_view.notify("串口已经连接")
} }
}else{ }else{
let ret = DataWrap.closeSerial(); let ret = DataWrap.closeSerial();
if(ret == 0){ if(ret == 0){
button.text = "打开串口" button.text = "打开串口"
uart_open = false uart_open = false
serial_select_view.notify("串口已经关闭")
} }
} }
} }

View File

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

View File

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

View File

@ -44,7 +44,7 @@ public:
int SetProto(QSerialProto *); int SetProto(QSerialProto *);
int SetListener(SerialListener *); 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); void GetSetting(QString baudRate, QString dataBits, QString stopBits, QString flow);
signals: signals:
private: private:

View File

@ -63,7 +63,7 @@ int ShareData::ShowDataInQML(QString x)
int ShareData::SendUartData(const char *data) int ShareData::SendUartData(const char *data)
{ {
if(nullptr != 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 0;
} }
return -1; return -1;