Dimensions of characters
-
Hi everyone.
I have a question referred to the built of characters. Is the character included in a rectangle depending on the size and not on the font? If yes, how can I save the dimensions of this rectangle? -
Hi,
What rectangle ?
What font ?
What are you doing ? -
This post is deleted!
-
@SGaist I try to explain better the problem.
We want to place another visible cursor in qtextedit.
For doing this we try to use labels, but we need to understand its right position on the y axis to put it in.
If all letters have the same size, it isn't a problem, we can do it with QRect of function QtextEdit::cursorRect() and the cursor appears in the position that we want to.
But when we switch from a larger size (i.e 72) to a smaller one (i.e 12) and we continue to write on the same line, we resize our cursor and now we don't have any reference to place it.
So we think that maybe there can be a general rule for fonts (for example all characters of size 9 have to fit a specific rectangle of specific dimensions indipendently on the font) that we can use for doing some proportion and calculate the right position. And if this rectangle exist how can we take its dimensions having only the size of font. -
Hi
Im not really sure what you are doing with those labels,
but if its about font and a box around a string then
https://doc.qt.io/qt-5/qfontmetrics.html#boundingRect
can be used to get the rectangle for a given text string.