简体   繁体   English

QNetworkAccessManager 如何检查是否有待处理的请求?

[英]QNetworkAccessManager how to check whether there is pending request?

In qt4.8, where there is still the qhttp class, I could use http->hasPendingRequests() to check whether there is still pending requests.在 qt4.8 中,仍然存在 qhttp 类,我可以使用http->hasPendingRequests()来检查是否还有待处理的请求。 But in qt5, we are forced to use the QNetworkAccessManager class to manage the http link.但是在qt5中,我们被迫使用QNetworkAccessManager类来管理http链接。 How could I achieve this checking?我怎么能实现这个检查?

Better late than never, although I could not find related docs, try something like:迟到总比不到好,虽然我找不到相关的文档,请尝试以下操作:

QNetworkAccessManager myManager;

// Some requests here...

QList<QNetworkReply *> list =
    myManager->findChildren<QNetworkReply *>();

Note that above is only tested with Qt4 and Qt5 (but might be true for coming versions),请注意,以上仅使用 Qt4 和 Qt5 进行了测试(但可能适用于即将推出的版本),
And actually, this is how Qt itself finds them for destruction.实际上,这就是 Qt 本身找到它们进行销毁的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM