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