Simplest way to download from the HTTP is below::
connect(&http,SIGNAL(done(bool)),this,SLOT(httpdon e()));
In the header file......Make the following changes...
QHttp http;
QFile file;
private slots:
bool on_pushButton_clicked();
void httpdone();
signals:
void done();
in the Qthttp.cpp file...
bool QtHttp:n_pushButton_clicked()
{
QString strUrl="http://www.blabla.com//file";
QUrl url = QUrl::fromUserInput(strUrl);
QFileInfo fileInfo(url.path());
QString strhost=url.encodedHost();
QString filename=fileInfo.fileName();
file.setFileName("C:\\Qt\\QHttp\\"+filename);
http.setHost(url.host(),url.port(80));
http.get(url.path(),&file);
if(!file.open(QIODevice::WriteOnly))
{
QMessageBox::warning(NULL,"warning","file is not opened",QMessageBox::Ok);
}
file.write(http.readAll());
http.close();
return true;
}
void QtHttp::httpdone()
{
file.close();
Q_EMIT done();
}