QRectF rect(0, 0, 100, 50); QTransform transform; transform.scale(2, 1); // Scale x by 2 QRectF scaledRect = transform.mapRect(rect);
QImage image("filename.png"); QTransform transform; transform.translate(image.width()/2, image.height()/2); // Move origin to center of image transform.rotate(30); // Rotate by 30 degrees transform.translate(-image.width()/2, -image.height()/2); // Move origin back to top-left corner QImage rotatedImage = image.transformed(transform);In this example, we load an image from a file and create a QTransform object. We use the `translate` function to move the origin of the transform to the center of the image, then the `rotate` function to rotate the image clockwise by 30 degrees. We then use `translate` again to move the origin back to the top-left corner of the image, and apply the transform to the image using the `transformed` function. The resulting `rotatedImage` will show the original image rotated by 30 degrees around its center. These examples both use the Qt library, specifically the QtCore and QtGui modules.