Skip to content

Explicitly round up implicit sizes in FormLayout

Proposed fix for BUG:457675

The implicit size of an item may not be an integral number of pixels. GridLayout internally ceils the implicitHeight and implicitWidth properties, but not the Layout.* attached properties, so we need to call Math.ceil ourselves whenever we set a Layout property based on the implicit size.

If a non-integral layout parameter has a fractional part <0.5 then the layout engine will end up rounding it down to a pixel-aligned value that is not quite large enough to fit the contents (see included test case).

For word-wrapped text, the slightly-too-small size causes the text to inappropriately wrap. If the implicit size of the wrapped text gets rounded differently it causes an infinite loop in the layout.

Marking this as a draft because it changes the behavior of existing clients: items with non-integral implicit widths will sometimes lay out exactly 1 pixel larger.

I don't think that this will actually be a problem for existing code. Implicit sizes already get rounded up about half the time and layouts should already be prepared for that. It didn't break any of the layouts I tried it with (basically my own code plus a bunch of KCMs).

Edited by Connor Carney

Merge request reports

Loading