回复: 求问QSerialPort在多线程环境下如何使用?
#11 [jienze 06-05 09:36]
读串口是被动接收的,可以放在一个线程中,利用中断模式等待数据到来!
写串口是主动模式的,可以直接操作。问题是如果在不同线程中,怎样对同一个串口进行操作?
方法有很多种,
我用的的方法是在线程中,传递串口描述符指针。
#12 [谢谢谢123456 02-29 11:28]
我刚也遇到了同样的问题。
#13 [踢飞season 03-03 12:47]
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QSerialPort(0x28fd74), parent's thread is QThread(0x15f10f68), current thread is testThread(0x24257ed8)
楼主,我把串口地址传到线程中总提示这个怎么解决
#14 回 踢飞season 的帖子 [johnyork 03-03 23:36]
踢飞season:QObject: Cannot create children for a parent that is in a different thread.
(Parent is QSerialPort(0x28fd74), parent's thread is QThread(0x15f10f68), current thread is testThread(0x24257ed8)
楼主,我把串口地址传到线程中总提示这个怎么解决 (2016-03-03 12:47)
你要用moveToThread把串口对象从主线程移动到QThread线程中才行。
#15 [zxwmail 07-05 12:07]