#ifndef TTT_H#define TTT_H#include <QObject>#include <QDebug>class TTT : public QObject{ Q_OBJECTpublic: TTT(QObject *parent = 0){ connect(this, SIGNAL(destroyed()), this, SLOT(tmp())); }signals:public slots: void tmp(){ qDebug()<<"END"; }};#endif // TTT_H#include <QApplication>#include "TTT.h"int main(int argc, char **argv){ QApplication app(argc, argv); TTT *ttt = new TTT; delete ttt; return app.exec();}
Worker *w = new Worker;QThread *t = new QThread;w->moveToThread(t);connect(this, SIGNAL(destroyed()), w, SLOT(stop()));connect(w, SIGNAL(finished()), t, SLOT(quit()));connect(w, SIGNAL(finished()), w, SLOT(deleteLater()));t->start();