Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.2.4
-
None
Description
If you change the font size of an empty QTextDocument then the height of the cursor (in a QML TextEdit for example) won't match this font size. This is a bad experience for users of rich text editors, as they'd expect the cursor size to match their selected font size, even if they haven't typed anything yet.
I've had a little look around the Qt internals (with QQuickTextControlPrivate::rectForPosition being the main area of interest) and it seems that the height of the cursor comes from the height of the line at whatever position the cursor is at. However, if there are no lines in the cursor's block's layout, then a height of 10 is returned.
For some reason, the line count of the initial block in a QTextDocument has 0 lines, even though the document and the block itself have 1 line.
An example of the cursor being the wrong height
If you change the font size before typing, you'll see that the cursor actually shrinks, but once you start typing it'll become the right size. Look in the console and you'll see that before typing there are no lines.
An example showing the line counts
Other examples
My example is a QML application but I've also observed similar behaviour in Qt Widgets applications. For example, in Calligra Words if you change increase font size the cursor won't increase in size until you start typing. And if you backspace until the start of the block then the cursor will return to the default height, even though the larger font size is still set.
I've set the affected version as 6.2.4, since that's what I used to create the first example, but I suspect that this problem exists in newer versions of Qt as well.