May 19, 2011

yshurik yshurik
Lab Rat
40 posts

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?

6 replies

May 19, 2011

ZapB ZapB
Robot Herder
1356 posts

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.

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

May 19, 2011

yshurik yshurik
Lab Rat
40 posts

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.

May 19, 2011

ZapB ZapB
Robot Herder
1356 posts

Does the listener need to be in between or can it just listen along with the existing connected objects?

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

May 19, 2011

yshurik yshurik
Lab Rat
40 posts

Well, I would like to do some filtering and no deliver some signals

May 19, 2011

koahnig koahnig
Mad Scientist
2112 posts

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.

May 19, 2011

ZapB ZapB
Robot Herder
1356 posts

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.

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

 
  ‹‹ Seperate Path and File from a QString or a QFile      Set a project to build 64 bit dll? ››

You must log in to post a reply. Not a member yet? Register here!