QPixmap originalImage("image.jpg"); QPixmap scaledImage = originalImage.scaledToHeight(200);
QPixmap originalImage("image.png"); QPixmap scaledImage = originalImage.scaledToHeight(400, Qt::SmoothTransformation);In this example, we load an image from a file called "image.png" into a QPixmap object called originalImage. We use the scaledToHeight function again, but this time we specify an additional parameter to control the quality of the scaling. The Qt::SmoothTransformation value indicates that we want a high-quality, antialiased scaling algorithm to be used. Overall, the QPixmap scaledToHeight function is a useful tool for resizing images in a way that preserves their aspect ratio. It can be used in a variety of applications, including image processing and user interface design.