views:

140

answers:

2

Is there a way to see which signals are fired, and if there is a slot connected to them? Ideally, we'd like to see all signals, not just those of a particular class or method; e.g. QSignalSpy only allows us to track specific signals of specific instances.

In our application, we've seen performance problems because of a signal being emitted twice from different components. In the end, it turned out that there was a second instance of a class that should have only been there once. Knowing which signals are emitted exactly helps in debugging this.

Signals are called via QMetaObject::invoke*, I was hoping to find something there to hook into, but I found nothing obvious.

A: 

QSignalSpy could help you.

From docs,

The QSignalSpy class enables introspection of signal emission.QSignalSpy can connect to any signal of any object and records its emission.

The docs has examples too..

liaK
I am aware of signal spy, sorry for not mentioning that. The downside of it, is that it does not allow me to see *all* emitted signals, just specific signal signatures of a single class or instance.
Ivo
@Ivo, I am not sure whether there is anything which lists all the signals emitted but yes `QSignalMapper` is to track the signals from the specified instance..
liaK
Qt maintains a list of signals internally, which is a struct containing at least the string containing the signal name and signature. That much I gathered from looking at the code. However, unfortunately, this is buried very deep in Qt.
Ivo
A: 

Maybe this post is useful for you

Bander
I will have to take a look at it, thanks!
Ivo