Op 3-11-2015 om 14:13 schreef René J.V. Bertin:
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?
Yeah. It simply doesn't make a lot of sense. What is the function of the
public fired() slot? And why do you connect to that from outside of the
timer class itself? What is the function of stuffing the timers in a
list instead of giving them a parent? Why do you need polling at all to
check the state of the "various items"?
André
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest