Results 1 to 6 of 6

Thread: QLabel to display an image and preserve the aspect ratio

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QLabel to display an image and preserve the aspect ratio

    Quote Originally Posted by yogeshgokul View Post
    At the time of scaling the image. You can use these options:
    Qt Code:
    1. Qt::KeepAspectRatio
    2. Qt::KeepAspectRatioByExpanding
    To copy to clipboard, switch view to plain text mode 
    Whatever suits your requirement.
    So you propose to create a custom widget, re-implement paintEvent and draw a properly scaled image, right?

    Is there a way to do that via Designer without writing code - this is what I was thinking about.

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLabel to display an image and preserve the aspect ratio

    Quote Originally Posted by psih128 View Post
    So you propose to create a custom widget, re-implement paintEvent and draw a properly scaled image, right?
    Yes Subclass QLabel and scale the Pixmap properly in resizeEvent();

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.