We are developing a Qt5 webkit application which loads html5\javascript\css3 pages. Trying to download a file of size 3MB. But file is downloaded with empty even though there is not network error.
Here's code for the same
QNetworkRequest request(url);
QNetworkReply *reply = mNetworkManager->get(request);
QObject::connect(mNetworkManager,SIGNAL(finished(QNetworkReply*)),this, SLOT(downloadFinished(QNetworkReply*)));
In downloadFinished slot:
if (reply->error() != QNetwrkReply::NoError){
qDebug()<<"download is failed"<< reply->errorString()
}
else {
QFile file(location);
if(file.open(QIODevice::WriteOnly)) {
file.write(reply->readAll());
}
}
reply->deleteLater();
There is no error reported message but file is created with empty data.That means QNetworkReply->error is QNetworkReply::noError but QNetworkReply::readAll returns NULL.
Could any one tell possibilities for this failure? Any suggestions on fix?