I found that it does not "refresh" the GUI.
Rather than introducing a new thread I wrote this routine that "refreshes" the GUI and returns true on connect and false on a timeout.
bool Connector::waitForConnection(quint16 ms)
{
myTimer.start();
do {
qApp->processEvents();
return true;
} while(myTimer.elapsed() < ms);
return false;
}
bool Connector::waitForConnection(quint16 ms)
{
QTime myTimer;
myTimer.start();
do {
qApp->processEvents();
if (tcpSocket.state() == QAbstractSocket::ConnectedState)
return true;
} while(myTimer.elapsed() < ms);
return false;
}
To copy to clipboard, switch view to plain text mode
I could of used a QTimer and used the Connect SIGNAL but I was concerned about what could happen if I got a Connect SIGNAL at the same time that the Timer Exprires.
It would be simplest if the QTcpSocket had a timeout parameter; but that is where this thread started.
Bookmarks