在下载文件的时候,如果下载的是压缩包之类的就没有问题
可是当下载的是文本的时候,打开下载的文本,发现文本是空的...
可是如在显示progressDialog那里用qdebug输出文本的内容的话
打开下载的文本就发现里面有正确的内容了,好奇怪啊,哪位大神知道这是怎么回事啊?
代码如下:
void FtpClient::downloadFile(const QString &fileName)
{
file = new QFile(downloadDir+fileName);
if(!file->open(QIODevice::ReadWrite)) {
qDebug()<<file->errorString();
return;
}
ftp->get(fileName,file);
progressDialog->setLabelText(tr("downloading %1...").arg(fileName));
progressDialog->show();
}
void FtpClient::updateProgressDialog(qint64 readBytes, qint64 totalBytes)
{
qDebug()<<readBytes<<totalBytes<<file->readAll();//就是这里
progressDialog->setMaximum(totalBytes);
progressDialog->setValue(readBytes);
}