Happy to help. A couple of suggestions:

- Since itemBoundingRect and rect are already QRectF (which is floating point based), there is no need to cast width() and height() to float. They already are. I was assuming they were QRect, which is integer based and thus needed casting to avoid rounding errors on division. (if either height or width of the rect is less than the height or width of the bounding rect, integer division would always yield zero as the scale factor).

- You should move the check on polygonItem validity to right after the dynamic_cast. If it is null, then retrieving the oldPolygon a few lines later will blow up.

- You should also use qgraphicsitem_cast<> instead of dynamic_cast<> in all of your resizing methods.