[Interest] [External] Text: remove empty space at top or get its size

Murphy, Sean Sean.Murphy at centauricorp.com
Tue Apr 13 23:12:13 CEST 2021

> I want to center vertically image and text. But when I'm trying to, it does not
> look centered, because of an empty space at the top of the text.
> What I mean is illustrated by this image:
> The blue rectangle looks a bit above the text. However, these two controls are
> centered actually. The second image illustrates this by showing text's bounding rectangle.
> Is there any way to remove this few empty lines of pixels at the top in the text control?
> Or at least somehow get its height so I can take this into account manually?

Have you looked at font metrics (https://doc.qt.io/qt-5.12/qml-qtquick-fontmetrics.html)? I've never played around with the parts your concerned about specifically, but it looks like maybe your answer may lie somewhere in the ascent and/or tightBoundingRect() areas?


More information about the Interest mailing list