Actually there is a very simple solution for this problem. There are two things you should modify:
- Set the scaled content to true (mentioned above)
-
Set the label’s size policy to ignored
QLabel lblImage; lblImage->setPixmap( QPixmap( "big_image.jpg" ) ); lblImage->setScaledContents( true ); lblImage->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored );
If the lblImage
is resizing automatically, the image will stretch to the size of the label.