I don't know why you are persisting with using QHttp when both the posts in this thread and the advice in the Qt documentation tell you to use QNetworkAccessManager. From the QHttp docs:
This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
and
This class provides a direct interface to HTTP that allows you to download and upload data with the HTTP protocol. However, for new applications, it is recommended to use QNetworkAccessManager and QNetworkReply, as those classes possess a simpler, yet more powerful API and a more modern protocol implementation.
You do have a good reason... don't you? If you were using the recommended network classes then you would find there are examples doing exactly this sort of thing.
Here is your code without your hack and slash commenting,. and with some comments of my own.
QHttp http;
// Deprecated class, please use QNetworkAccessManager
// Define a file
file.setFileName("C:\\Qt\\OCZToolbox\\"+fileName+" .vic");
// file is not open for read or write
connect (&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
http.
setHost(url.
host(),
QHttp::ConnectionModeHttp) ;
// Try to get a the URL response into the file that is not open for writing
http.get(url.path(),&file);
// That was an asynchronous operation you just started, so we get here immediately
// Ignore the fact that you have asked QHttp to write the file and try to do it yourself
// Open for writing and truncate any existing file
// write nothing to the file and then close
file.close();
http.close();
QHttp http; // Deprecated class, please use QNetworkAccessManager
// Define a file
QFile file;
file.setFileName("C:\\Qt\\OCZToolbox\\"+fileName+" .vic");
// file is not open for read or write
connect (&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
http.setHost(url.host(),QHttp::ConnectionModeHttp) ;
// Try to get a the URL response into the file that is not open for writing
http.get(url.path(),&file);
// That was an asynchronous operation you just started, so we get here immediately
// Ignore the fact that you have asked QHttp to write the file and try to do it yourself
// Open for writing and truncate any existing file
file.open(QIODevice::WriteOnly);
// write nothing to the file and then close
file.close();
http.close();
To copy to clipboard, switch view to plain text mode
I have no idea why you are surprised that the file is empty.
Bookmarks