Home > Back-end >  Mixed vs2010 QT4 programming environment, a serial port programming garbled
Mixed vs2010 QT4 programming environment, a serial port programming garbled

Time:09-20

Everyone a great god, please advice!
I mixed in vs2010 + QT4 programming environment, wrote a simple serial interface software, but when they receive Chinese characters appear garbled, receiving Numbers and letters, no problem, could you tell me how to solve? Thank you very much!
To send and receive function is as follows:
 
//send function
Void Serial_Qt: : SendData publishes the event ()
{QString sendData_str=UI. Send_textEdi - & gt; text();
Char * sendData_char;
QByteArray Datatem=sendData_str. ToLocal8Bit ();
SendData_char=Datatem. Data ();
MyCom - & gt; Write (sendData_char);
UI. Send_textEdi - & gt; clear();
Sleep (1000);
}

//receive function
Void Serial_Qt: : readMyCom ()
{
QByteArray temp.
If (myCom - & gt; BytesAvailable ())//judge whether there is a byte
{
Temp=myCom - & gt; ReadAll ();//returns the byte read
//int byteLen=myCom - & gt; BytesAvailable ();//return the serial buffer bytes
UI. Rcv_textEdit - & gt; Append (temp);
}
return;
}
  • Related