Hello all,
I have an application that must download files in the background. I separate
this process off into a separate thread so that it does not interfere with the
UI. Unfortunately, when it starts downloading, it uses the full pipe that it
has access to and adversely affects the rest of the network - causing other
internet connections to slow to a crawl. The application is installed on
networks which I do not control and cannot throttle it that way. What I would
like to do is have the application not eat so much bandwidth during the
download.
The code I am using to download is pretty run of the mill (error checks removed
for brevity):
void ContentDownloader::downloadFile(QUrl url, QString filename)
{
QNetworkRequest request(url);
QNetworkAccessManager* _manager = new QNetworkAccessManager(this);
QNetworkReply* reply = _manager->get(request);
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QFile file(filename);
file.open(QIODevice::WriteOnly);
file.write(reply->readAll());
file.close();
}
Thoughts on how to make it "slow down"? I have been toying with the
setReadBufferSize in the reply but does not really seem to change anything.
Thanks!
-Jason
- - - - - - - - - - - - - - - - - - - - - - -
Jason R. Kretzer
Lead Application Developer
[email protected]<mailto:[email protected]>
"quidquid latine dictum sit altum videtur"
[cid:[email protected]]
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest