QT Socket编程过程问题
2017-08-09 10:35
1536 查看
客户端:
[WARNING T10868] 8-9 10:25:35 91 QObject: Cannot create children for a parent that is in a different thread.
(Parent is QTcpSocket(0x23f72c42a40), parent's thread is IpuCommIpu(0x88bd9bfb78), current thread is QThread(0x23f72c250a0)
[WARNING T10868] 8-9 10:25:35 93 QObject: Cannot create children for a parent that is in a different thread.
(Parent is QTcpSocket(0x23f72c42a40), parent's thread is IpuCommIpu(0x88bd9bfb78), current thread is QThread(0x23f72c250a0)
class IPUCOMM_EXPORT IpuComm : public QThread
class IPUCOMM_EXPORT IpuCommIpu : public IpuComm
服务端:
[WARNING T5392] 8-9 10:25:41 573 QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
[WARNING T5392] 8-9 10:25:41 574 QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
class IPUCOMM_EXPORT IpuComm : public QThread
class IPUCOMM_EXPORT IpuCommHost : public IpuComm
解决方法:
1、针对IpuCommHost,做如下更改:
IpuCommHost::IpuCommHost(quint16 port)
: IpuComm()
{
///////////////////////// 将IpuCommHost对象,移动到自身对应线程
this->moveToThread(this);
}
2、针对IpuCommIpu,做如下更改:
IpuCommIpu::IpuCommIpu()
: IpuComm()
{
///////////////////////// 将IpuCommIpu对象,移动到自身对应线程
this->moveToThread(this);
}
同时,通过IpuCommIpu线程,去调用void QAbstractSocket::connectToHost(const
QHostAddress &address,
quint16
port,
OpenMode
openMode = ReadWrite);
[WARNING T10868] 8-9 10:25:35 91 QObject: Cannot create children for a parent that is in a different thread.
(Parent is QTcpSocket(0x23f72c42a40), parent's thread is IpuCommIpu(0x88bd9bfb78), current thread is QThread(0x23f72c250a0)
[WARNING T10868] 8-9 10:25:35 93 QObject: Cannot create children for a parent that is in a different thread.
(Parent is QTcpSocket(0x23f72c42a40), parent's thread is IpuCommIpu(0x88bd9bfb78), current thread is QThread(0x23f72c250a0)
class IPUCOMM_EXPORT IpuComm : public QThread
class IPUCOMM_EXPORT IpuCommIpu : public IpuComm
服务端:
[WARNING T5392] 8-9 10:25:41 573 QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
[WARNING T5392] 8-9 10:25:41 574 QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
class IPUCOMM_EXPORT IpuComm : public QThread
class IPUCOMM_EXPORT IpuCommHost : public IpuComm
解决方法:
1、针对IpuCommHost,做如下更改:
IpuCommHost::IpuCommHost(quint16 port)
: IpuComm()
{
///////////////////////// 将IpuCommHost对象,移动到自身对应线程
this->moveToThread(this);
}
2、针对IpuCommIpu,做如下更改:
IpuCommIpu::IpuCommIpu()
: IpuComm()
{
///////////////////////// 将IpuCommIpu对象,移动到自身对应线程
this->moveToThread(this);
}
同时,通过IpuCommIpu线程,去调用void QAbstractSocket::connectToHost(const
QHostAddress &address,
quint16
port,
OpenMode
openMode = ReadWrite);
相关文章推荐
- QTcpSocket使用过程中的一些问题记录
- RT3070 USB WIFI 在连接socket编程过程中问题总结
- QTcpSocket通信编程时阻塞与非阻塞的问题
- RT3070 USB WIFI 在连接socket编程过程中问题总结
- QTcpSocket使用过程中的一些问题记录
- Qt中采用多线程实现Socket编程-跨线程调用问题
- QT4.8.5编程过程中遇到的问题及解决办法
- Qt中采用多线程Socket编程的问题
- QTcpSocket使用过程中的一些问题记录
- 初识的网络编程,Socket的小问题.
- [转]Qt编程中的常见问题
- Linux下Socket编程的端口问题( Bind(): Address already in use )
- 关于编程过程中的一些疑惑及问题
- MFC Socket编程时遇到的多字符、Unicode字符集问题
- Java Socket 网络编程问题剖析
- qt下编程出现问题归纳
- LWIP UDP socket编程 可以指定本地端口号及发送长度不能太长问题分析
- 5.关于QT中的网络编程,QTcpSocket,QUdpSocket
- QT5 没办法引用 QTcpSocket 问题的解决
- socket编程问题汇总(一)