Hi.
I am changing QHttp to QNetworkAccessManager, but i can't find replacement for QHttp::request and QHttp::clearPendingRequests in QNetworkAccessManager
it is must work under QT4.6 and 5
thanks.
Hi.
I am changing QHttp to QNetworkAccessManager, but i can't find replacement for QHttp::request and QHttp::clearPendingRequests in QNetworkAccessManager
it is must work under QT4.6 and 5
thanks.
Last edited by stevocz; 11th April 2014 at 12:44.
QNetworkAccessManager hands out QNetworkReply objects for each request that you are initiating.
See get(), head(), put(), post() for that.
QNetworkReply::abort() can be used to terminate any such request.
Cheers,
_
stevocz (14th April 2014)
but i can't fint function witch returns unique identifier as QHttp::request
As I said, each request is encapsulated by a request handler, an instance of QNetworkReply.
e.g. if you call QNetworkAccessManager::get() three times, each call returns a new instance of QNetworkReply, each of these objects signalling progress, error, when it is done, etc.
Cheers,
_
stevocz (14th April 2014)
thanks. now it works
But I have to save all reply into list for aborting
Last edited by stevocz; 14th April 2014 at 08:22.
Qt Code:
QList<QNetworkReply*> listOfRequests;To copy to clipboard, switch view to plain text mode
or:
Qt Code:
static int reqId() { static int nextReq = 0; return ++nextReq; } QHash<int, QNetworkReply*> listOfRequests; listOfRequests.insert(reqId(), networReply); int key = listOfRequests.key(networkReply);To copy to clipboard, switch view to plain text mode
etc.
True, but if you always want to abort all unfinished() requests at some point then you could also have a signal and connect that to each network reply object's deleteLater() slot.
Assuming that deleting a reply will abort it, but I think that is quite a safe guess.
Cheers,
_
Bookmarks