Thanks thawkins, but I think it´s not exactly what I need.

I have followed the mice colliding example and I´ve created a timer event:

The .h file:

Qt Code:
  1. #ifndef CHIP_H
  2. #define CHIP_H
  3.  
  4. #include <QtGui/QColor>
  5. #include <QtGui/QGraphicsItem>
  6. #include <QObject>
  7.  
  8. class Chip : public QGraphicsItem
  9. {
  10. Q_OBJECT
  11.  
  12. public:
  13. Chip(const QColor &color, int x, int y, const QString &tipo, const qreal &ancho, const qreal &alto, const QPixmap &pixmap);
  14.  
  15. QRectF boundingRect() const;
  16. QPainterPath shape() const;
  17. void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget);
  18.  
  19. protected:
  20. void mousePressEvent(QGraphicsSceneMouseEvent *event);
  21. void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
  22. void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
  23. void timerEvent(QTimerEvent *event);
  24. [/B]
  25. private:
  26. int x, y;
  27. QColor color;
  28. QString tipo;
  29. QPixmap pixmap;
  30. qreal ancho;
  31. qreal alto;
  32. QList<QPointF> stuff;
  33. };
To copy to clipboard, switch view to plain text mode 

And in the .cpp file I have reimplemented the timer event:

Qt Code:
  1. #include "chip.h"
  2. #include "loc.h"
  3.  
  4. #include <QtGui>
  5. #include <QtSql>
  6.  
  7.  
  8. loc_position_t loc_pos;
  9.  
  10. Chip::Chip(const QColor &color, int x, int y, const QString &tipo, const qreal &ancho, const qreal &alto, const QPixmap &pixmap)
  11. {
  12. this->x = x;
  13. this->y = y;
  14. this->color = color;
  15. this->tipo = tipo;
  16. this->ancho = ancho;
  17. this->alto = alto;
  18. this->pixmap = pixmap;
  19.  
  20. setZValue(1);
  21.  
  22. setFlags(ItemIsSelectable);
  23. setAcceptsHoverEvents(true);
  24. startTimer(5000);
  25.  
  26. }
  27.  
  28. ...
  29.  
  30. void Chip::timerEvent(QTimerEvent *)
  31. {
  32. ...
  33. }
To copy to clipboard, switch view to plain text mode 

Now my problem is I get the error:

Qt Code:
  1. :: === chip2, Debug ===
  2. chip.cpp:24: error: `startTimer' undeclared (first use this function)
  3.  
  4. ...
To copy to clipboard, switch view to plain text mode 

Why is that? I have rerun qmake and the Q_OBJECT macro is the .h file. I cannot find why the error. Can anyone help?