the while (1)
{
Myserial - & gt; WaitForReadyRead ();
QByteArray data=https://bbs.csdn.net/topics/myserial-> readAll ();
QString STR=data;
QDebug () & lt;Emit sendData publishes the event (STR);
Data. The clear ();
Myserial - & gt; ReadAll (). The clear ();
}
I want to separate the part of a serial port to read data into a new thread of run , but I Qserialport object pointer is in the main thread, I now want to use the connect preach to participate in the past, but the run not slot function, how to implement the==
CodePudding user response:
Serial port operation involves interaction, so can't completely on the child thread, because the child thread has been while accounted for,CodePudding user response:
A newcomer just learning QT half a month, meng thread hereCodePudding user response:
Can use global variables, a serial port for data, can be directly used in the threadCodePudding user response:
Cannot pass in the child thread constructor Qserialport object pointer?CodePudding user response:
Trough passing parameters can movetothread method, using the signalCodePudding user response:
The readyread () signalCodePudding user response:
https://blog.csdn.net/hebbely/article/details/79428336CodePudding user response:
Method that can be movetothread 1, can use the method of using signal trough passing parameters and then USES the groove function;2, can receive serial data on child thread on the inside