View Full Version : Catching all Signals from widget in QTest

30th July 2014, 09:17

I need to catch all signals emitted from a widget using QSignalSpy (or something else), is there a way to do that? It can by only number of those signals without any other info.

30th July 2014, 11:14
You can list all signals of a type by iterating over the methods of its QMetaObject and checking for QMetaMethods for signals.

You could then create a list of signal spys, each connected to one signal, or connect all signals to a custom slot in a receiver object.


5th August 2014, 14:23
If somebody want to know how to do that I paste my code.

#include <QSignalSpy>

class QAllSignalSpy : public QList<QSignalSpy*>

explicit QAllSignalSpy(QObject *parent){
QObject *object = parent;
const QMetaObject *me = object->metaObject();
int metaCount = me->methodCount();
for(int i = 0;i<metaCount;i++){
QMetaMethod mm = me->method(i);
if (mm.methodType() == QMetaMethod::Signal){
QString method = QString::number(2)+ mm.methodSignature().constData();
this->append( new QSignalSpy(object, method.toLatin1().constData() ) );

int signalCount(){
int all = 0;
for(int i=0;i<this->size(); i++)
all += this->at(i)->count();
return all;

enjoy! ;)

11th December 2017, 00:14
I have just published a tiny header-only library which does exactly this: QSignalInspector (https://github.com/j-ulrich/QSignalInspector)