[Qt-interest] QApplication::Process

Sean Harmer sean.harmer at maps-technology.com
Thu May 27 14:46:51 CEST 2010


Hi,

On Thursday 27 May 2010 13:30:28 Serge wrote:
> I need to download a file via HTTP and display progressDialog.
> While file is downloaded procedure is waiting the end of download process:
> 
> 		while (m_downloading)
> 			QApplication::processEvents();
> 
> this makes 90% processor use
> 
> am i using wrong method?
> if i would use QEventLoop::loop, would it be better?
> Are there any alternatives?

Yes, do this in an event driven manner using QNetworkAccessManager (QNAM) and 
QNetworkReply. See the docs at:

http://doc.qt.nokia.com/4.7-snapshot/qnetworkaccessmanager.html
http://doc.qt.nokia.com/4.7-snapshot/qnetworkreply.html

So, use QNAM to issue a request. Then with the QNetworkReply pointer that you 
get back connect up to the QNetworkReply::downloadProgress() signal:

http://doc.qt.nokia.com/4.7-snapshot/qnetworkreply.html#downloadProgress

See the above docs for more details.

HTH,

Sean



More information about the Qt-interest-old mailing list