[Interest] Best way to invoke a slot after some time with QObject::sender

Till Oliver Knoll till.oliver.knoll at gmail.com
Tue Aug 28 08:36:19 CEST 2012


Am 28.08.2012 um 04:10 schrieb Preet <prismatic.project at gmail.com>:

> Hiya,
> 
> I have a project where I'm trying to asynchronously reply to a signal.
> So if ObjectA sends ObjectB a signal, ObjectB will send ObjectA a
> reply signal at some later point in time. 

That sounds like "broken by design" to me: you'd have a dependency circle here! In order to *connect* to a signal you have to *know* the signal emiter's class. So signals should only go one way: bottom up.

That said, your problem sounds a little bit what QNetworkAccessManager is solving: you have multiple clients that request (by method call!) something from the network, they get a handle (object) for the time being (with which they can also e.g. abort the current operation), the QNAM does its work asynchronously and finally emits a signal (actually several ones in each state transition) once it's done (it doesn't know its clients though!).

Why wouldn't that approach work in your case?

Cheers,
  Oliver


More information about the Interest mailing list