PDA

View Full Version : Preserving aspect ratio of image



Banjo
16th January 2009, 03:45
Hello

I have designed a simple MainWindow in Designer with a number of Labels across the top of the window These labels act as a banner which is always displayed independent of which page of the Stacked widget below is current. In my code, I set the pixmap of each label as below (I am using PyQt).

self.lblLogo.setPixmap(QPixmap(':/Logo.jpg'))

How do I ensure that the aspect ratio of the image is preserved whenever the user resizes the main window or the application is displayed on screens of various sizes ? Is this the correct way to go about it?

Thanks

aamer4yu
16th January 2009, 05:21
You can scale your image with QImage::scaled with Qt::KeepAspectRatio option

jpn
16th January 2009, 14:39
See QxtLetterBoxWidget (http://doc.libqxt.org/latest/classQxtLetterBoxWidget.html).