I have a simple class inherits QGraphicsRectItem class. I want it to write "testing" in the mousePressEvent() but it doesn't...where am i doing wrong?i examined the tutorials but couldn't find my fault...

Qt Code:
  1. QGraphicsScene scene(0,0,200,200);
  2. scene.addItem(new MyItem(0));
  3. QGraphicsView view(&scene);
  4. view.show();
  5. return a.exec();
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #ifndef MYITEM_H_
  2. #define MYITEM_H_
  3. #include <QGraphicsItem>
  4. class MyItem:public QGraphicsRectItem
  5. {
  6. public:
  7. MyItem(QGraphicsItem* parent=0,QGraphicsScene *s=0);
  8. virtual ~MyItem();
  9.  
  10. QRectF boundingRect() const;
  11. protected:
  12. void mousePressEvent(QGraphicsSceneMouseEvent *e);
  13. void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
  14.  
  15. };
  16.  
  17. #endif /*MYITEM_H_*/
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include "MyItem.h"
  2. #include <QtGui>
  3. MyItem::MyItem(QGraphicsItem* p,QGraphicsScene *s):
  4. {
  5.  
  6. }
  7.  
  8. MyItem::~MyItem()
  9. {
  10. }
  11.  
  12. void MyItem::mousePressEvent(QGraphicsSceneMouseEvent* e){
  13. qDebug("testing");
  14. QGraphicsRectItem::mousePressEvent(e);
  15.  
  16. }
  17.  
  18. void MyItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget )
  19. {
  20. painter->fillRect(10,10,50,50,QBrush(Qt::red,Qt::SolidPattern));
  21. }
  22.  
  23. QRectF MyItem::boundingRect() const
  24. {
  25.  
  26. }
To copy to clipboard, switch view to plain text mode