Cannot resize a label control that displays a picture
-
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 -
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.
-
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
-
[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.