QHttp::requestFinished() //[signal]
我的QHttp结束时,并没有发送这个signal ?这个signal不是http结束时发送的吗?
/*-----------------------------------------------------这是我的代码*/
#include "downclass.h"
DownWindow::DownWindow()
{
http = new QHttp(this);
setupUi(this);
connect(pushButton, SIGNAL(clicked()), this, SLOT(downButtonSlot()));
connect(http, SIGNAL(requestFinished (int id, bool error)), this, SLOT(httpFinishSlot(int id, bool error)));
}
void DownWindow::downButtonSlot()
{
pushButton->setEnabled(false);
QUrl url(lineEdit->text());
QFileInfo info(url.path());
file = new QFile(info.fileName());
file->open(QIODevice::WriteOnly);
http->setHost(url.host());
result = http->get(url.path(), file);
}
void DownWindow::httpFinishSlot(int id, bool error) //下载结束并没有执行这个函数
{
QMessageBox::information(this, "prompt", "The file down over");
if (error)
{
file->remove();
file->close();
delete file;
file = NULL;
return;
}
file->close();
delete file;
file = NULL;
}
void DownWindow::closeSlot()
{
file->close();
delete file;
close();
}
/*********************/
[ 此贴被XChinux在2006-09-14 19:26重新编辑 ]