I am trying to use a QTimer with a mouseMoveEvent to highlight some cards. I do not know what I am doing wrong. If someone can give me some useful hints.

Qt Code:
  1. //In Constructor
  2. QTimer *timer = new QTimer(this);
  3. connect(timer, SIGNAL(timeout()), this, SLOT(highlightCard()));
  4. timer->start(500);
  5.  
  6. void Canvas::mouseMoveEvent(QMouseEvent *event)
  7. {
  8. if (event->type() == QEvent::MouseMove)
  9. {
  10. x_pos = event->pos().x();
  11. y_pos = event->pos().y();
  12. }
  13. }
  14.  
  15. void Canvas::highlightCard()
  16. {
  17. QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect(this);
  18. effect->setColor(QPalette::Highlight);
  19.  
  20. for (int i = 0; i < MAXCARDS; i++)
  21. {
  22. if (cardIconPlayer[i]->pos() == QPoint(x_pos, y_pos))
  23. cardIconPlayer[i]->setGraphicsEffect(effect);
  24. }
  25. }
To copy to clipboard, switch view to plain text mode