主要问题是报了这个错误:
(Parent is QSerialPort(0x1917e750), parent’s thread is QThread(0x8d05a0), current thread is QThread(0x19154460)
然后我就在各个地方打Log看线程。最后觉得是下面这个问题,求大佬指点。
主函数内:
my_thread = new QThread();
local_serial = new SePort();
local_serial->moveToThread(my_thread);
然后我通过connect调用了SePort类内的槽函数:
connect(port, &QSerialPort::readyRead, this, &SePort::rcv_data, Qt::QueuedConnection);
connect(time, &QTimer::timeout, this, &SePort::rcv_dataFromBuffer, Qt::QueuedConnection);
然后结果就是rcv_dataFromBuffer和rcv_data这两个槽的线程和my_thread 的不一致,但是通过对象调用方法的时候,线程是一样的。
想问问有没有大佬指点下。