QRectF srcRect(0, 0, 100, 100); QTransform transform; transform.translate(50, 50); QRectF dstRect = transform.mapRect(srcRect);
QGraphicsItem* pItem; QRectF srcRect = pItem->boundingRect(); QTransform transform; transform.rotate(45); QRectF dstRect = transform.mapRect(srcRect);In this example, we have a QGraphicsItem object pItem and want to map its bounding rectangle to a new coordinate system that is rotated by 45 degrees. We create a QTransform object that rotates the coordinate system by 45 degrees, and then call the mapRect() function on this transform object with the bounding rectangle of the pItem object as the argument. The resulting dstRect object contains the mapped rectangle in the rotated coordinate system. Package Library: Qt.