This question already has an answer here:
- Qt signal slot connection - QNetworkAccessManager 1 answer
I was checking some simple examples of using QNetworkAccessManager and I found this (Assuming that manager is a QNetworkAccessManager:
QNetworkRequest request;
request.setUrl(QUrl("http://www.someserver.com"));
QNetworkReply *reply = manager->get(request);
connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(slotError(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
this, SLOT(slotSslErrors(QList<QSslError>)));
As far as I understand, the call to manager->get will send out a GET request. The slots to handle the answer to that request, however, are connected only after the call is sent, which does not seems to make sense for me. Here my question:
- isn't it a problem to connect the slots to the signals after the request is done? Can it happen that the request is done and the signals are emitted before the connection takes place, and hence, that the signals are missed and never processed by the corresponding slots?
Thanks!
L.
UPDATE: As pointed out by cyber_raj, this question has been already answered here: Qt signal slot connection - QNetworkAccessManager