Results 1 to 3 of 3

Thread: Problem with downloading a webpage

  1. #1
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    23
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Problem with downloading a webpage

    Hi again,
    I want to download source code from a webpage - I've got following code:

    Qt Code:
    1. QHttp * http;
    2. QFile * file;
    3. file = new QFile("something.txt");
    4.  
    5. QUrl url("SomeUrl");
    6. http = new QHttp;
    7. http->setHost(url.host(), url.port(80));
    8. http->get(url.path(), file);
    To copy to clipboard, switch view to plain text mode 

    Everything compiles well, but my file is sometimes empty or it has not whole webpage code, what should I do?
    Last edited by Fenix Voltres; 25th June 2009 at 17:45.

  2. #2
    Join Date
    Sep 2008
    Posts
    25
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with downloading a webpage

    Hi!

    The get function is asynchronous, it sends a request to the server and returns immediately, the QHttp object will emit a requestFinished signal when the request completed. You probably tried to read the results from the file before the request completed.
    Note that get function returns a request id, and requestFinished has a request id parameter, this way you'll know which request finished.

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

    Fenix Voltres (25th June 2009)

  4. #3
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    23
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Problem with downloading a webpage

    Thanks, now I see what this phrase means - I was deleting pointer to a file while httpRequestFinished signal was emitted, but I didn't check it's id - and i t was other signal
    Last edited by Fenix Voltres; 25th June 2009 at 20:07.

Similar Threads

  1. QHTTP POST problem
    By oscar in forum Qt Programming
    Replies: 5
    Last Post: 10th October 2009, 19:58
  2. QHttp proxy problem
    By andre.rigon in forum Qt Programming
    Replies: 2
    Last Post: 28th September 2008, 21:19
  3. QHttp download file problem.
    By fengtian.we in forum Qt Programming
    Replies: 12
    Last Post: 12th June 2007, 09:39
  4. QProcess problem in accessing stdout
    By aruna in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2006, 17:56
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Tags for this Thread

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.