class SafeTimer : public QObject { Q_OBJECT public: SafeTimer(QObject *parent = 0) : QObject(parent) { timer = new QTimer(this); connect(timer, SIGNAL(timeout()), SIGNAL(timeout())); } ~SafeTimer() { timer->disconnect(this); timer->setParent(0); timer->deleteLater(); } void start(int msecs) { timer->start(msecs); } signals: void timeout(); private: QTimer *timer; };