Results 1 to 3 of 3

Thread: Resizing a QLabel with a pimap. Won't shrink!

  1. #1
    Join Date
    Sep 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Resizing a QLabel with a pimap. Won't shrink!

    I'm using a QLabel to display images (I retreive the images from an SQLite database).

    The label is part of a widget with a few other buttons and labels.

    By using the QLabel::setScaledContents(true) (or the equivalent in Qt Designer). I can make it so the QLabel showing this image expands if the widget expands and the image displayed will expand accordingly.

    But it won't resize smaller than the image's original size.

    I can see why this behaviour might be desired in some cicumstances but it's not what I want.

    I can work around the problem by setting the image in the QLabel to be a down-sized (scaled) image which gives me a smaller minimum size but then (obviously) the quality of the image is reduced if I expand it.

    Any ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Resizing a QLabel with a pimap. Won't shrink!

    A more advanced way to solve your problem can be create a subclass of QLabel and to reimplement the QWidget::resizeEvent method in way to use a down-sized version of pixmap when the qlabel becomes smaller than the pixmap.
    Last edited by mcosta; 17th September 2010 at 13:03. Reason: updated contents
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Sep 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Resizing a QLabel with a pimap. Won't shrink!

    Thanks for the reply,

    Yeah, I realised that I could subclass the QLabel to make it work. It just seems like there might have been an easier way (not that it would be too hard to subclass it).

Similar Threads

  1. Replies: 3
    Last Post: 2nd March 2010, 21:58
  2. Prevent a QLabel resizing the parent QWidget
    By danc81 in forum Qt Programming
    Replies: 6
    Last Post: 10th November 2009, 21:54
  3. Replies: 1
    Last Post: 29th September 2009, 20:44
  4. Saving Pimap to Bitmap
    By dbrmik in forum Newbie
    Replies: 3
    Last Post: 26th November 2008, 14:34
  5. Shrink QMainWindow to Minimum Size
    By kloffy in forum Qt Programming
    Replies: 4
    Last Post: 17th February 2008, 18:54

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.