Results 1 to 7 of 7

Thread: QHttp to QNetworkAccessManager

  1. #1
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default QHttp to QNetworkAccessManager

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QHttp to QNetworkAccessManager

    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,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    stevocz (14th April 2014)

  4. #3
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QHttp to QNetworkAccessManager

    but i can't fint function witch returns unique identifier as QHttp::request

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QHttp to QNetworkAccessManager

    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,
    _

  6. The following user says thank you to anda_skoa for this useful post:

    stevocz (14th April 2014)

  7. #5
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QHttp to QNetworkAccessManager

    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.

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHttp to QNetworkAccessManager

    Quote Originally Posted by stevocz View Post
    thanks. now it works

    But I have to save all reply into list for aborting
    Qt Code:
    1. QList<QNetworkReply*> listOfRequests;
    To copy to clipboard, switch view to plain text mode 

    or:

    Qt Code:
    1. static int reqId() { static int nextReq = 0; return ++nextReq; }
    2.  
    3. QHash<int, QNetworkReply*> listOfRequests;
    4.  
    5. listOfRequests.insert(reqId(), networReply);
    6.  
    7. int key = listOfRequests.key(networkReply);
    To copy to clipboard, switch view to plain text mode 

    etc.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QHttp to QNetworkAccessManager

    Quote Originally Posted by stevocz View Post
    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,
    _

Similar Threads

  1. Replacing QHttp.get() with QNetworkAccessManager
    By Grisu in forum Qt Programming
    Replies: 2
    Last Post: 1st February 2013, 02:32
  2. QNetworkAccessManager or QHttp help required
    By prasad.borkar in forum Newbie
    Replies: 3
    Last Post: 20th April 2011, 07:30
  3. QNetworkAccessManager and QHttp doesn't sends anything
    By corrado in forum Qt Programming
    Replies: 2
    Last Post: 29th May 2010, 22:20
  4. QNetworkAccessManager or QHttp
    By mind_freak in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2009, 20:24
  5. QNetworkAccessManager vs QHttp
    By jiveaxe in forum Newbie
    Replies: 3
    Last Post: 17th February 2009, 14:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.