A couple of days ago, I have encountered quite a strange bug. When working and organizing layouts for elements in different parts of the system, our QA reported that somehow texts are not aligned properly, and this happens on MAC only. At first, I have thought that I have made a typo in setting content margins. However, I have found out that margins were perfectly identical, thus this was not a problem. Then, for some reason, I have decided to remove checkbox from a grid layout. And what happened? Layout started to behave as perfectly aligned.
After observing this behavior, I have decided to create experimental Qt project, and see the behavior of check boxes in the grid layout, so I would be able to properly report a bug to Qt’s bug tracker if this is really a Qt issue. After doing so, I have observed that this is really a Qt issue. The behavior was the following:
- On Windows, everything worked exactly as expected, i.e. layout margins were not changed.
- On MAC, for some reason the margins were changed, and I am not sure why.
This Qt behavior is a bit annoying, because you expect that elements in the layout would not affect the layout which is in higher level of hierarchy. However, for this issue, the workaround exists. You just need to put checkbox to a separate layout, and the parent layout won’t be affected (but the containing layout will).
The following link is exact bug report: https://bugreports.qt.io/browse/QTBUG-62617