How to get list of objects+slots connected to some object+signal?
-
I have some "transmitter" object and have a need to get list of all slots+objects connected to my signal in transmitter. How can it be done?
-
I think you would have to build a slightly modified version of Qt to do this. The connections list is maintained inside private QObjectData (iirc). So you would need to provide an accessor function for this data.
Why do you need this information? Qt signals are supposed to provide loose coupling of components. i.e. an emitter shoudl not care about who is listening.
-
I would like to install my "listener" in between. I can not change sources of objects on both sides so I would like to break connections, then restore connections with my "listener" in the middle.
-
Does the listener need to be in between or can it just listen along with the existing connected objects?
-
Well, I would like to do some filtering and no deliver some signals
-
Do you do the connection between objects in your code or is it completely out of your hands?
If you do it yourself, it would be easy to divert the signals to your code. So, you really want to break the signals. -
Can you not just call disconnect() from outside of the object of which you do not have source control and reconnect them via your intermediary? Or is the problem that you do not know which connections to disconnect? If so then easiest way to find out is to build modified Qt to expose the info that you need because at present I do not think that QObject exposes this information in its public interface.