Now I have done something like this, but it does not work.
graphicsscene.cpp
Qt Code:
  1. void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *e)
  2. {
  3. pos=e->scenePos();
  4. if(e->button() == Qt::LeftButton)
  5. {
  6. if(itemAt(pos))
  7. { QGraphicsScene::mousePressEvent(e); }
  8. else
  9. {
  10. EllipseItem *item = new EllipseItem(pos.x()-5, pos.y()-5,10,10);
  11. item->setFlags(QGraphicsItem::ItemIsMovable);
  12. addItem(item);
  13. }}}
To copy to clipboard, switch view to plain text mode 
ellipseitem.cpp
Qt Code:
  1. void EllipseItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
  2. {
  3. setRect((e->scenePos().x()-5),(e->scenePos().y()-5),10,10);
  4. end = e->scenePos();
  5. setFlag(QGraphicsItem::ItemIsSelectable, true);
  6.  
  7. if(isSelected() && e->button() == Qt::RightButton)
  8. {
  9. sc = new QGraphicsScene;
  10. LineItem *linie = new LineItem((e->scenePos().x()),(e->scenePos().y()),end.x(),end.y());
  11. sc->addItem(linie);
  12. }}
To copy to clipboard, switch view to plain text mode 
lineitem.cpp
Qt Code:
  1. void LineItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
  2. {
  3. startpkt = e->scenePos();
  4. endpkt = e->scenePos();
  5. setLine(startpkt.x(),startpkt.y(),endpkt.x(),endpkt.y());
  6. }
To copy to clipboard, switch view to plain text mode 
I draw two ellipse (this works) in the scene and if I choose one and move the mouse to the other the should appear the line(this don't work).
I don't know whats the problem...
Please help