I puzzled with 4 and 5. I have used moveToThread function to move the m_spDevPort to the monitor thread, but its member m_spSerialPort still stayed in the main thread.
your problem is that m_spSerialPort's parent is not set.
CSerialPort::CSerialPort()
{
// Create serial port object
m_spSerialPort = new QSerialPort(this); //<<<<<<<<<<<<<<<< Pass the parent while object creation.
// 1. print the thead where m_spSerialPort lived in
printThreadID();
// Timer for send command
}
CSerialPort::CSerialPort()
{
// Create serial port object
m_spSerialPort = new QSerialPort(this); //<<<<<<<<<<<<<<<< Pass the parent while object creation.
// 1. print the thead where m_spSerialPort lived in
printThreadID();
// Timer for send command
m_tQueryTimer = new QTimer;
}
To copy to clipboard, switch view to plain text mode
Bookmarks