我是 QT 新手,遇到了以下问题。
下载返回一个空文件:
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 呼叫消息框之前 - 一切正常:
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();
}
有任何想法吗?