我是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