Determine signals connected to a given slot in Qt

I think Qt stores the slots a given signal is connected to, so that when you emit it all receivers are called, therefore you can access the list of receivers:

For debugging purposes, you have:

void QObject::dumpObjectInfo ()

Dumps information about signal
connections, etc. for this object to
the debug output.

This function is useful for debugging,
but does nothing if the library has
been compiled in release mode (i.e.
without debugging information).

And the list of slots a signal is connected:

int QObject::receivers ( const char *
signal ) const [protected]

Returns the number of receivers
connected to the signal.

The metaObject() gives you the QMetaMethod for the slot, but it has no information about its connections.

However, if you know the objects, you can go over all the the signals (using the meta object, testing the method type for signal) and build a reverse index with the slots receivers() gives you.

Leave a Comment