static inline void startOpenTimer(DeviceCommThread *dev, QTimer *&t){ if ( !t) { t = new QTimer(dev); QObject::connect(t, SIGNAL(timeout()), dev, SLOT(openDevice())); } // just a single-shot timer. we'll know when to start it again... t->setSingleShot(true); t->start(1000);}class DeviceCommThread : public QThread{Q_OBJECT...};void DeviceCommThread::run(){ fDone = false; startOpenTimer(this, fOpenTimer); int sleepBetweenPoll = 2; // keep the thread alive until we're supposed to be done while (!fDone) { QThread::sleep(sleepBetweenPoll); }}