Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.6, 5.15.0, 6.0.1
-
None
Description
When adding a word-wrapped label in a layout, the sizeHint is wrong. In attachment a minimal example is provided. Next to that a screenshot is provided of how it looks on Qt 6.0.1 in combination with macOS 10.15.
The way a label is word wrapped depends on the font, fontSize, ... So to reproduce this issue on another platform it might be necessary to make the text of the label a bit longer or shorter. It's easiest to reproduce if it's just too long to fit on 2 lines (so only a few characters have to go on a 3rd line)
I debugged the problem a bit and it looks strange to me that inside QLayout::totalSizeHint(), the heightForWidth is asked for a width that includes the margins of the parentWidget while the layout can not use these margins to place the label.
Changing
s.setHeight(heightForWidth(s.width() + side));
into
s.setHeight(heightForWidth(s.width()));
seems to fix the problem for me.