我是QT新手,遇到以下问题。通过http加载文件
下载返回一个空文件:
QFile file("book.gif");
QHttp http;
if (file.open(QIODevice::WriteOnly))
{
http.setHost("www.geocities.com");
http.get("/mslerm/images/qtbook.gif", &file);
http.close();
file.close();
}
但如果关闭HTTP调用的MessageBox之前 - 一切正常:
QFile file("book.gif");
QHttp http;
if (file.open(QIODevice::WriteOnly))
{
http.setHost("www.geocities.com");
http.get("/mslerm/images/qtbook.gif", &file);
QMessageBox msgBox;
msgBox.setText(http.errorString());
msgBox.exec();
http.close();
file.close();
}
什么想法?
感谢您的详细回复 – mmatviyiv