1
我有以下代碼:QFile.write()只寫大文件的第一22MBytes
QNetworkAccessManager *nam = new QNetworkAccessManager(this);
QNetworkReply *re = nam->get(QNetworkRequest(QUrl("http://somesite/ai.bin")));
QEventLoop loop;
QObject::connect(reply, SIGNAL(readyRead()), &loop, SLOT(quit()));
int timeInSeconds = 10;
QTimer *idleTimer = new QTimer(this);
connect(idleTimer,SIGNAL(timeout()),&loop,SLOT(quit()));
idleTimer->setInterval(timeInSeconds *1000);
idleTimer->start();
loop.exec();
//save
QFile file("C:/a.jpg");
file.open(QIODevice::WriteOnly);
file.write(re->readAll());
ui->dbgOut->insertHtml("<font color='green'>OK</font><br>");
如果遠程文件爲5 MB,它的工作原理,BT如果該文件是ABOT 50或500MB,則程序只保存前22 MB,而該過程仍然在後臺下載文件。
我在做什麼錯?
工程就像一個魅力。謝謝!就一個問題。你知道我可以如何下載這個文件逐塊?問候 – user3343366