Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cannot resize a label control that displays a picture
QtWS25 Last Chance

Cannot resize a label control that displays a picture

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    OlafMeding
    wrote on last edited by
    #1

    A label control that displays a picture can not be resized smaller than the original .jpg image (after a layout is applied). As a workaround, the minimum label sizes had to be changed from 0 to 1. Any idea why I had to do this?

    This is for Qt version 4.8.6 on Windows 7.

    PS How do I include a picture in a post (I don't want to upload somewhere and add a link here)?

    Thanks for your help
    Olaf

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Label picture is considered content, just like text. You wouldn't want your text clipped and you usually don't want that to happen with pictures either. The default (0) means something like auto - the minimum size is the size of the content. You can override that with 1 or any other value. What you did is not a workaround. It's a legitimate setup.

      This forum does not provide image hosting. The only way to post a picture is via external link.

      1 Reply Last reply
      0
      • O Offline
        O Offline
        OlafMeding
        wrote on last edited by
        #3

        Chris

        Thanks for your reply. What you explained makes sense for displaying text. However the behavior for displaying an image is unexpected. Also, I had set the scaledContents property to true.

        Perhaps there a better control to display a .jpg image?

        Anyway, the current implementation makes Qt more difficult to use. And that is too bad.

        Olaf

        1 Reply Last reply
        0
        • Chris KawaC Online
          Chris KawaC Online
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          [quote author="OlafMeding" date="1409295528"]What you explained makes sense for displaying text. However the behavior for displaying an image is unexpected.[/quote]To you :)
          [quote author="OlafMeding" date="1409295528"]
          Perhaps there a better control to display a .jpg image?[/quote]You can use a custom widget and draw the image however you like it in the paintEvent(). Should be few lines of code at most.
          [quote author="OlafMeding" date="1409295528"]
          Anyway, the current implementation makes Qt more difficult to use.[/quote]Again - to you and your use case. Images in labels are very often used as various UI icons, markings, placeholders for animations etc. We don't want them to crop that content. Qt is a general library. The general case is easy. The less general case (like yours) is possible. For miracles you need to wiggle a bit.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved