默认Qt 连接类型 AutoConnection 这意味着如果发出的信号来自另一个线程,则当控制返回到当前线程的事件循环时,它的插槽将被排队并调用(如 QueuedConnection )。由于你的线程中有一个阻塞循环,控件永远不会返回到线程的事件循环......The default Qt connection type is AutoConnection which means that if the emitted signal is from another thread, it's slot is queued and invoked when control returns to the current thread's event loop (like a QueuedConnection). Since you have a blocking loop in your thread, the control is never returns to the thread's event loop...尝试用 DirectConnection连接你的插槽。类似于:connect (manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished()), Qt::DirectConnection);void ReqProcessor::getUpdates (){ QString url = baseURL; QNetworkAccessManager *manager = new QNetworkAccessManager(this); QNetworkReply *reply; QEventLoop loop; url.append ("getupdates?timeout=100"); connect (manager, SIGNAL(finished(QNetworkReply*)), &loop, SLOT(quit()), Qt::DirectConnection); reply = manager->get (QNetworkRequest (QUrl (url))); loop.exec(); updates = reply->readAll ();} 还有一个错误,我的程序缺少QApplication或QCoreApplication。And aother mistake was, my program was lacking a QApplication or QCoreApplication. 这篇关于Qnetworkaccesmanager没有发出“完成”的信息。信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 17:41