Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QLabel won't fit an image without margins
I create two labels on a vertical layout using Qt designer. The top label has a image and the lower label has text. For both labels, I right clicked > Layout Alignment > Center Horizontally, Top.
The problem I have is the top label which has the image has a big space separating it from the lower label. I selected it and then clicked geometry in the right panel, it expanded to show x, y, width, and height. The width x height is 327 x 78. The actual dimension of the image is 284 x 67. I can't modify the values because they are grayed out.
How can I eliminated the excess space in the label not used by the image so that the top and lower labels look as if they were almost one label without the big space separating them?
for the layout, check the layout margins.
there is also one that defines the space between widgets.
I changed the layoutSpacing to 0 saved and ran the app, still get the same result.
also layoutHorizontalSpacing ?
You could set Maximum Height on the label with image
to match image dimensions.
can u show a picture ?
The label widget has a margin itself (the distance between the frame and the contents) that is independent of the layout's margins. Have you tried setting the label margin to be 0 as well?
I changed the height and width of maximumSize to that of the image dimensions and still I get the same result. When I select the label that has the image, I can't find a layoutHorizontalSpacing for it.
Here is the link to the result when I run the program:
QLabel margin is 0
Have you put a vertical spacer at the bottom? If not the layout will always try to distribute the space between the widgets.