All pastes #974741 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-04-07 00:23 UTC
rendered paste body
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;
};