QHttp get()下载网络图片时,文件已创建,但是为0字节
代码如下:
QHttp http;
bool HttpGet::getFile(const QUrl &url,const QString filepath)
{
QFile *file;
file = new QFile(filepath);
if (!file->open(QIODevice::WriteOnly))
{
delete file;
file = 0;
return false;
}
http.setHost(url.host(), url.port(80));
http.get(url.path(),file);
http.close();
return true;
}
求解。。。。