开发者

explicitly listening for signals

I'm new 开发者_如何学Pythonto Qt, but I have some experience in C and Java. I'm trying to write a program that makes multiple TCP connections to different servers on the network. the ip's are read in from a text file and i use connectToHost to establish a connection then the socket is added to a QList. this happens in a loop.

the problem is that i only start receiving the connected() signals when the program exits the loop, this causes some unexpected behaviour. so is there a way to poll for signals in the loop?


call QCoreApplication::processEvents() inside your loop to avoid freezing


You can use QAbstractSocket::waitForConnected()

http://doc.qt.io/qt-5/qabstractsocket.html#waitForConnected

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜