Quote Originally Posted by jiveaxe View Post
As I wrote in my previous code QTemporaryFile should be in the same scope of http.
QHttp::get() is asynchronous. If you do something like this:
Qt Code:
  1. void f() {
  2. temp.open();
  3. QHttp *http = new QHttp;
  4. http->setHost("localhost");
  5. http->get("/file",&file);
  6. }
To copy to clipboard, switch view to plain text mode 
QHttp::get returns immediately, before actually download file. http is a heap allocated object, so it survives at and of f(), but file not, and is destroyed. When http obtains file from webserver, tries to write to an invalid location (because file is no longer existant).
You should declare both QHttp and QTemporaryFile as pointers and create their instances with new, and catch QHttp signal to know when http request is finished. However QHttp example explains well.