I was wodering if it matter where the connection is made on an object. For example, usally I do it before I make the call that might emit signals, but sometimes I have to do it afterwards if it's node on for example a QNetworkReply that doesnt exists until the call is made. Maybe I have to make some checks as well before the connection can be made.
Is there any chance that the signal can be emitted BEFORE a connection was made to connect this signal to a slot?
For example:
ClassA::function() {
ClassB b;
b.someCall();
connect(&b, SIGNAL(finished()), this, SLOT(someSlot()));
}
ClassB::someCall() {
emit finished();
}
Would the slot be called here? This might not be a very practical example since you would probabbly just use a return value in this case. But in some cases I do this, for example if "someCall" is a routine that you can step though and it can fail, either if a network-request inside of that routine fails, or if we get some error right in the beginning. Either way, the "failed()" signal should be emitted and have a slot to handle any kind of failure. For example;
ClassB::someCall() {
allocate "something"
if(something == NULL) emit finished();
QNetworkReply *reply = someNetworkAccessManager.put(something);
connect(reply, SIGNAL(finished()), this, SIGNAL(finished()));
}
So here we have a call where it can emit finished() pretty much straight away, or after a while. If I create the connection after I make this call, will the first finished() be catched?