QT 关于serialport和thread的问题

主要问题是报了这个错误:
(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 的不一致,但是通过对象调用方法的时候,线程是一样的。
想问问有没有大佬指点下。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值