[Interest] subclassed QTimer

René J.V. Bertin rjvbertin at gmail.com
Tue Nov 3 14:13:46 CET 2015


Hi,

I wanted to add a quick timer to an editor class to check the state of the various items that editor can handle. It'd be cumbersome to subclass the edit items to add a timeout slot to them, or to extend the editor class so a timeout slot would get called with the appropriate item. The easiest way seemed to be to subclass QTimer:

class QItemTimer : public QTimer {
public:
	QItemTimer(QObject *parent, Item *item)
		: QTimer(parent)
	{
		_item = item;
	}
public slots:
	void fired();
protected:
	Item *_item;
};

and then do

	QItemTimer *t = new QItemTimer(0, _item);
	connect(t, SIGNAL(timeout()), t, SLOT(fired()));
	t->start(1000);
	timerList.append(t);

but as far as I can tell my fired slot isn't being called.

I'm probably overlooking something obvious?

René



More information about the Interest mailing list