Results 1 to 12 of 12

Thread: Reading web content with QNetworkAccessManager and QNetworkReply

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Reading web content with QNetworkAccessManager and QNetworkReply

    So I should do something like this:

    Qt Code:
    1. void MainWindow::getXML()
    2. {
    3. QNetworkRequest request(QUrl("[my_address]"));
    4. NetAccMan.get(request);
    5. connect(&NetAccMan, SIGNAL(finished(QNetworkReply*)), this, SLOT(parseXML(QNetworkReply*)));
    6. }
    7.  
    8. void MainWindow::parseXML(QNetworkReply *networkReply)
    9. {
    10. [...]
    11.  
    12. NetAccMan->disconnect();
    13. networkReply->deleteLater();
    14. }
    To copy to clipboard, switch view to plain text mode 

    Would it be correct? Or deletion in this case should be arranged in different way?

    thanks in advance
    best regards
    Tomasz

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Reading web content with QNetworkAccessManager and QNetworkReply

    Delete looks fine to me. You don't want to connect/disconnect your QNetworkAccessManager with every request though, just make the connection once in the MainWindow constructor and wait until the MainWindow is destroyed for automatic disconnection.
    Last edited by ChrisW67; 10th February 2011 at 00:45.

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

    Tomasz (10th February 2011)

Similar Threads

  1. Replies: 2
    Last Post: 18th January 2012, 15:01
  2. Replies: 1
    Last Post: 9th October 2010, 23:54
  3. Replies: 2
    Last Post: 18th June 2010, 11:04
  4. Problems reading content of QFile
    By martinn in forum Newbie
    Replies: 12
    Last Post: 6th April 2010, 18:42
  5. Replies: 2
    Last Post: 9th January 2010, 02:03

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
  •  
Qt is a trademark of The Qt Company.