[Interest] subclassed QTimer

Daniel França daniel.franca at gmail.com
Tue Nov 3 14:24:38 CET 2015


If still don't work with the Q_OBJECT macro, maybe trying with setTimerType
(Qt::PreciseTimer)?

Em ter, 3 de nov de 2015 às 14:20, Frank Hemer <frank at hemer.org> escreveu:

> Hi René,
>
> On Tuesday 03 November 2015 14:13:46 René J.V. Bertin wrote:
> > 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?
>
> I'm missing the Q_OBJECT macro
>
> Frank
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151103/a7cbbf46/attachment.html>


More information about the Interest mailing list