I solved the problem finally with the code:

Qt Code:
  1. QVariant saItemSteelNode::itemChange(GraphicsItemChange change, const QVariant &value)
  2. {
  3. double s;
  4. if (change == QGraphicsItem::ItemPositionChange) {
  5. QPointF newPos = value.toPointF();
  6. if(Settings::snapOn()==1)
  7. {
  8. s=Settings::snapSize();
  9. newPos.setX(floor(newPos.x()/s)*s);
  10. newPos.setY(floor(newPos.y()/s)*s);
  11. };
  12. //check collision with other nodes
  13. p.addEllipse(newPos,diameter/2.0+1,diameter/2.0+1);
  14. QList<QGraphicsItem*> sl=scene()->items(p);
  15. sl=saScene::refineItems(sl,saItemSteelNode::TypeSteelNode);
  16. sl.removeAll(this);
  17. if(sl.count()>0)//collision
  18. {
  19. newPos=pos();
  20. };
  21. emit itemPositionChanged();
  22. return newPos;
  23. };
  24. return QGraphicsItem::itemChange(change,value);
  25. return value;
  26. }
To copy to clipboard, switch view to plain text mode