Important: Please read the Qt Code of Conduct -

Text ImplicitHeight differences between iOS and Windows?

  • Newbie here - first post. I've done some searching for this issue, but no one has addressed the specific issue I have that I could find.

    I am working on a GUI that is currently being run on both Windows and iOS, using Qt5.4 and QML. We will eventually have to run on Linux as well, but I haven't tested this issue on that OS yet.

    Right now, we are handling the font size differences between Windows and iOS by using different pointSizes depending on the operating system. The rest of QML components size themselves based on resolution and Layouts. All Text currently uses the "Tahoma" family.

    I noticed that the vertical positioning of our fonts on the iOS looked slightly off compared to the Windows GUI. For instance, if I have a Rectangle QML component with a Text component centered vertically in it (I tried various means - both Layout and anchors), the font in the iOS always looked slightly off -- a little high. Everything looked fine in Windows.

    After some experimentation, I found that the implicitHeight of the Text Component in Windows included a space above the text that roughly equaled the space below that equals the Text component's baselineOffset. On iOS, this space above the Text does not exist -- the text is not "centered" vertically in the Text's implicitHeight -- it is flush against the top, while in Windows it is in the middle.

    So -- the layout/anchoring I do in the QML, which centers the Text vertically looks great on Windows, but is slightly off in iOS. Before I add more "if using iOS" conditionals for how I center Text components -- does someone have a suggestion how to handle vertically centering Text that would work for both OS's? Am I missing something crucial here?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You should test this with Qt 5.5. to see if the situation has changed in between

  • @SGaist

    Just rebuilt with Qt5.5, and still have the same issue. Bummer, I was hoping this would be a quick fix!

  • Lifetime Qt Champion

    Then you should take a look at the bug report system to see if it's something known

  • @SGaist

    Took a look at the bug reports -- judging by QTBUG-43226, which is still unresolved, there does seem to be some issues with Text.alignVCenter. I got pulled off on another task, but when I get back to this I am going to try using some different anchors for aligning the text to see if that will fix the issue.

Log in to reply