In fact I found the solution. One cannot use the QPolygonF, but need to use QGraphicsPolygonItem which provides the data() method.