Get QLineEdit Text Fields

How to get text fields for QLineEdit?

Notice the red lines in the screenshot that the fields that interest me are:

enter image description here

I tried qDebug() << ui->lineEdit->textMargins(); for the edit window from the screen, but printed QMargins(0, 0, 0, 0) , although the edit field has fields.

+6
source share
1 answer

Check out the QLineEdit drawing event . As you can see, many things affect this.

Besides textMargins there are things that can influence the values โ€‹โ€‹you are looking for.

  1. used style (see line 1942)
  2. and font properties - see QFontMetrics :: ascent and QFontMetrics :: descent

The style value is the most important, and you should find a way to get that value (probably a subclass is needed).

+3
source

All Articles