C++ (Qt)#include <QApplication> #include <QLabel> #include <QDebug> class Logger : public QObject{ Q_OBJECT public slots: void dead( QObject *obj ) { qDebug() << "Dead object" << obj; }}; class TestWidget : public QWidget{ Q_OBJECTpublic: TestWidget( Logger *log ) : QWidget( 0 ) { QLabel *lbl1 = new QLabel( this ); QLabel *lbl2 = new QLabel( this ); connect( lbl1, SIGNAL( destroyed( QObject * ) ), log, SLOT( dead( QObject * ) ) ); connect( lbl2, SIGNAL( destroyed( QObject * ) ), log, SLOT( dead( QObject * ) ) ); }}; int main( int argc, char *argv[] ){ QApplication app( argc, argv ); Logger log; TestWidget *w = new TestWidget( &log ); w->show(); app.exec(); delete w; return 0;} #include "main.moc"