QT中readyread()信号接收不到问题

u011043941 2013-10-28 07:49:13
在QT Creator里写一个接收端程序的时候,用到了一个connect(receiver, SIGNAL(readyRead()), this, SLOT(processPendingDatagram()));但是这货完全没有反应,我在网上查的时候看到好多人说可以用WaitForreadyread()解决,求教这个函数要怎么用?????
...全文
4319 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
vectorLayer 2014-02-25
  • 打赏
  • 举报
回复
This signal is emitted once every time new data is available for reading from the device. It will only be emitted again once new data is available, such as when a new payload of network data has arrived on your network socket, or when a new block of data has been appended to your device. readyRead() is not emitted recursively; if you reenter the event loop or call waitForReadyRead() inside a slot connected to the readyRead() signal, the signal will not be reemitted (although waitForReadyRead() may still return true). Note for developers implementing classes derived from QIODevice: you should always emit readyRead() when new data has arrived (do not emit it only because there's data still to be read in your buffers). Do not emit readyRead() in other conditions.
liyingju001 2014-02-15
  • 打赏
  • 举报
回复
引用 6 楼 u011043941 的回复:
问题解决了,在windows下,系统本身需要一个等待,而在linux下则不需要,所以没有添加等待的语句段的话,在windows下是无法发射信号的。目前我是这样理解的,如果哪里有问题,请大神们指教。。。。。
到底怎么解决的啊???求具体
u011043941 2013-12-04
  • 打赏
  • 举报
回复 3
问题解决了,在windows下,系统本身需要一个等待,而在linux下则不需要,所以没有添加等待的语句段的话,在windows下是无法发射信号的。目前我是这样理解的,如果哪里有问题,请大神们指教。。。。。
奶爸 2013-11-07
  • 打赏
  • 举报
回复
我也遇到了相似的问题!!! connect(udp, SIGNAL(readyRead()), this, SLOT(receive_message_slot())); 槽函数是我自己写的,但是貌似readyRead()这个信号一直没有发射啊!!! 我给udp发消息了 而且udp也绑定成功了 就是没反应啊!!! 求大神解释~~~
RabinSong 2013-10-30
  • 打赏
  • 举报
回复
pServer = new QLocalServer(this); connect(pServer, SIGNAL(newConnection()), this, SLOT(rxNewConnection())); pServer->listen(TEST_PROCESS_NAME); void rxNewConnection() { pSocket = pServer->nextPendingConnection(); if (pSocket != NULL) { connect(pSocket, SIGNAL(readyRead()), this, SLOT(rxMessage())); connect(pSocket, SIGNAL(disconnected()), pSocket, SLOT(deleteLater())); } }
ying_593254979 2013-10-30
  • 打赏
  • 举报
回复
你代码肯定有问题。这个信号肯定会触发的。不过问题是会触发多次。所以一次读取的数据可能是不全的。
u011043941 2013-10-28
  • 打赏
  • 举报
回复
用了一下bool b = connect(receiver, SIGNAL(readyRead()), this, SLOT(processPendingDatagram()));但是显示的是b的值是true呀。。。。
引用 1 楼 kfbyj 的回复:
connect 成功没。。 如果失败的话。运行的时候输出窗口有输出调试信息。。 会说明到底是哪里失败了。
狂风暴雨 2013-10-28
  • 打赏
  • 举报
回复
connect 成功没。。 如果失败的话。运行的时候输出窗口有输出调试信息。。 会说明到底是哪里失败了。

16,211

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧