Such things are usually done using QGraphcsItem::itemChange()