soxs060389
2nd November 2009, 23:36
Hi,
I am writing an application which requires me to download certain images from certain servers.
As this happens very frequently, the usage of signal and slots will make the gui get highcup.
So the question is:
How can I make download in snyc within a thread, without an exec() loop (or even with if there is no other way) like this (which does not work though):
QNetworkAccessManager net;
QNetworkReply *re (net.get( QNetworkRequest( QUrl( Qstring("www.blah.org/key") ) ) ));
if (re->waitForReadyRead(-1)) //! @bug this does not work as supposed, waitForRead returns false and returns INSTANTLY!!
qDebug() << "ReadyRead yeha!!!";
if (re->error()) {
qDebug() << "Can't download" << re->url().toString()
<< ":" << re->errorString();
} else {
img->load(re->readAll());
qDebug() << "Savin IMG";
}
delete re;
Thx for any reply.
I am writing an application which requires me to download certain images from certain servers.
As this happens very frequently, the usage of signal and slots will make the gui get highcup.
So the question is:
How can I make download in snyc within a thread, without an exec() loop (or even with if there is no other way) like this (which does not work though):
QNetworkAccessManager net;
QNetworkReply *re (net.get( QNetworkRequest( QUrl( Qstring("www.blah.org/key") ) ) ));
if (re->waitForReadyRead(-1)) //! @bug this does not work as supposed, waitForRead returns false and returns INSTANTLY!!
qDebug() << "ReadyRead yeha!!!";
if (re->error()) {
qDebug() << "Can't download" << re->url().toString()
<< ":" << re->errorString();
} else {
img->load(re->readAll());
qDebug() << "Savin IMG";
}
delete re;
Thx for any reply.