Priority: P2: Important
Affects Version/s: 5.12.6, 5.15.0, 6.0.1
Fix Version/s: None
Component/s: Widgets: Layout
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.
s.setHeight(heightForWidth(s.width() + side));
seems to fix the problem for me.