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
精彩评论