View Full Version : QHttp to QNetworkAccessManager
stevocz
11th April 2014, 12:37
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.
anda_skoa
11th April 2014, 12:46
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
11th April 2014, 13:05
but i can't fint function witch returns unique identifier as QHttp::request
anda_skoa
11th April 2014, 14:01
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, 08:08
thanks. now it works
But I have to save all reply into list for aborting
wysota
14th April 2014, 08:35
thanks. now it works
But I have to save all reply into list for aborting
QList<QNetworkReply*> listOfRequests;
or:
static int reqId() { static int nextReq = 0; return ++nextReq; }
QHash<int, QNetworkReply*> listOfRequests;
listOfRequests.insert(reqId(), networReply);
int key = listOfRequests.key(networkReply);
etc.
anda_skoa
14th April 2014, 09:59
But I have to save all reply into list for aborting
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,
_
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.