In my subclassed QGraphicsItem I'd like to draw some points with my mouse. One click with the mouse will result in one point showing up at the screen.When I doubleclick the item will be added to the scene. Is this possible or must the item be added to the scene and then updated? Can anybody help me understand how I can get the mousepressed-event to my Item?

MyScene.cpp
Qt Code:
  1. void MyScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
  2. {
  3. QGraphicsScene::mousePressEvent(mouseEvent);
  4. QPointF curPos= mouseEvent->lastScenePos();
  5.  
  6. //Create new item
  7. if(Mouse.iClicks == 0)
  8. {
  9. qDebug("Creating new spline.");
  10. newSpline = new itemSpline();
  11. }
  12.  
  13. newSpline->setVertices(curPos);
  14.  
  15. Mouse.iClicks++;
  16. }
  17.  
  18. void MyScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)
  19. {
  20. //TODO: Remove last point because dblclick takes one position.
  21.  
  22. qDebug("MyScene: DoubleClickEvent");
  23. if(newSpline->size() > 1)
  24. {
  25. qDebug("Adding item");
  26. this->addItem(newSpline);
  27. this->addRect(newSpline->boundingRect());
  28. }
  29. Mouse.iClicks = 0;
  30. }
To copy to clipboard, switch view to plain text mode 

MyItem.cpp

Qt Code:
  1. void item::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
  2. {
  3. painter->setRenderHint(QPainter::Antialiasing);
  4. painter->setBrush(Qt::lightGray);
  5. //Draw line.
  6. }
  7.  
  8. void item::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
  9. {
  10. //Catch mouse pos.
  11. m.setText("Test");
  12. m.exec();
  13. }
  14.  
  15. void item::mousePressEvent(QGraphicsSceneMouseEvent* event)
  16. {
  17. m.setText("Test");
  18. m.exec();
  19. }
  20.  
  21. void item::mouseMoveEvent(QGraphicsSceneEvent *event)
  22. {
  23. //Draw line from start pos to current pos.
  24. }
To copy to clipboard, switch view to plain text mode