Check paint event of QLineEdit. As you can see lots of stuff have effect on it.
Besides textMargins
there are stuff which can have impact on values which you are looking for.
- used style (see line 1942)
- and font properties - see QFontMetrics::ascent and QFontMetrics::descent
The style value is most important and you have to find way to get this value (probably subclass is needed).