Hi, I am new to QT. I have created object class QNetworkAccessManager main window as parent. Also registered to SIGNAL finished. It is working fine. But I want to know in which thread it will run. Will it block the main thread. If i need to perform sequence of get operation how should I need to write the code. Please give me some sample to understand concept properly.
+1
A:
It certainly does not run in the main thread, the calls to get() are asynchronous.
For example this would keep firing get requests:
while (condition) {
QNetworkRequest request;
request.setUrl(QUrl(m_ServerURL);
m_httpGetUpdatedFile->get(request);
}
You then have the slot for the finished signal which is processing the QNetworkReply. That slot basically should be getting called for each get request you make (even if it fails). If you need to keep track of when all your get requests have finished, you need to keep a track of how many you posted and then have your own finished flag or signal.
Phil Hannent
2010-02-26 09:37:12
Thanks replay.is the finish slot will run in main thread?If it run in main thread, it will block the main thread. For that I am using a sample as bellow.----QNetworkAccessManager manager;QEventLoop q;QTimer tT;tT.setSingleShot(true);connect(connect(QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("URL"))); tT.start(5k);q.exec(); ------Is this method is correct.I'm planning to run the above code in secondary thread.If I run it in secondary thread will it gives problem.
Umesha MS
2010-03-02 06:44:52