Results 1 to 3 of 3

Thread: QLabels autoresize to a pixmap?

  1. #1
    Join Date
    Jul 2009
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default QLabels autoresize to a pixmap?

    I am using Qt 4.5.2

    I have a .ui to which I assigned a horizontal layout, and placed into it a qLabel.

    The qLabel has scaledContents set to true.

    During program execution, I set a pixmap to that qLabel. This causes the label (and the entire MainWindow) to resize to the dimensions of that pixmap. This is not my desired behavior.

    I have found that in previous versions of Qt, qLabels had an autoResize property that determined whether they would expand themselves for larger content. It appears that in Qt 4.5.2, there is no longer such a property and the label will always automatically expand itself.

    If anyone knows how to disable autoresizing for the qLabel or if there is another type of widget onto which I can easily display a pixmap that will not resize unless the window is resized by the user, please let me know.

    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: QLabels autoresize to a pixmap?

    How about trying label->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fix ed); ?

  3. #3
    Join Date
    Jul 2009
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QLabels autoresize to a pixmap?

    Setting the sizes to "fixed" did not help: they still auto-resized to the size of the pixmap that i set to them, and even worse, then they did not stretch when i resized the window

    Setting the sizes to "ignored" produced the desired effect: the windows did not resize when a larger pixmap was set, they merely scaled the contents down. And, they stretched when I stretched the window and shrank when I shrank the window.

    This issue is now resolved.

    Thanks!

Similar Threads

  1. Qt 4.4 - Problem displaying pixmap in release mode
    By spawn9997 in forum Qt Programming
    Replies: 0
    Last Post: 19th August 2009, 19:40
  2. Performance problems with small pixmap
    By RThaden in forum Qt Programming
    Replies: 4
    Last Post: 9th July 2008, 15:14
  3. finding maximum scaling of a pixmap
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 31st March 2008, 14:32
  4. empty pixmap as a QLabel
    By tommy in forum Qt Programming
    Replies: 16
    Last Post: 11th December 2007, 21:15
  5. Invalid pixmap
    By munna in forum Newbie
    Replies: 2
    Last Post: 8th June 2006, 08:00

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.