Results 1 to 3 of 3

Thread: Preserving aspect ratio of image

  1. #1
    Join Date
    Jan 2008
    Posts
    39
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Preserving aspect ratio of image

    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

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Preserving aspect ratio of image

    You can scale your image with QImage::scaled with Qt::KeepAspectRatio option

  3. The following user says thank you to aamer4yu for this useful post:

    Banjo (21st January 2009)

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Preserving aspect ratio of image

    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    Banjo (21st January 2009)

Similar Threads

  1. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 15:36
  2. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 02:10
  3. aspect ratio of top-level widgets
    By urbangipsy in forum Qt Programming
    Replies: 3
    Last Post: 16th January 2007, 21:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.