QTcpClient successfully connects, but not to my server. Where is it connecting?

后端 未结 3 1528
小鲜肉
小鲜肉 2021-02-10 14:36

I have successfully built a thin client/server using Qt\'s Tcp Sockets API. I know it works very well, because I have sent plenty of data over the wire and verified it. Howeve

3条回答
  •  囚心锁ツ
    2021-02-10 15:23

    While QTEST_MAIN creates a QApplication and runs all your tests, it does so sequentially and not with an event loop. Therefore, while your socket can indeed connect to the server (meaning qTestSocket->waitForConnected() returns true), since the app doesn't return to an event loop, the QTcpServer's signal will not get emitted, and TcpCommSocketTest::connectDummyServer() never gets called.

    Try adding a call to qApp->processEvents() at the end of initTestCase(). It should let connectDummyServer() be called.

提交回复
热议问题