Results 1 to 2 of 2

Thread: QHttp and QTemporaryFile

  1. #1
    Join Date
    Sep 2007
    Posts
    29
    Thanks
    8

    Default QHttp and QTemporaryFile

    hi,
    i am trying to temporarily download a file for further processing. but for some reason QHttp::get does not like QTemporaryFile, whilst it works with a normal QFile.
    The temporary file actually gets created but remains empty.

    Qt Code:
    1. #include <QtCore>
    2. #include <QtNetwork/QHttp>
    3.  
    4. #include <cstdio>
    5.  
    6. int main(int argc, char* argv[])
    7. {
    8. QCoreApplication app(argc, argv);
    9. //QFile file("EDDC.TXT"); // works
    10. QTemporaryFile file; // doesn't work
    11. //file.open(); doesn't help
    12. QHttp http;
    13. http.setHost("weather.noaa.gov");
    14. http.get("/pub/data/observations/metar/decoded/EDDC.TXT", &file);
    15. app.connect(&http, SIGNAL(done(bool)), &app, SLOT(quit()));
    16. app.exec();
    17. getc(stdin); // block so the temporary file won't be deleted yet
    18. }
    To copy to clipboard, switch view to plain text mode 


  2. #2
    Join Date
    Sep 2007
    Posts
    29
    Thanks
    8

    Default Re: QHttp and QTemporaryFile

    problem solved: i had to call flush() on the file before accessing it. no idea though, why it only occured when creating a temporary file.

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.