Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.0.1
-
None
-
deepin V20
-
-
e99a883bd382ca950192bd66cafb2a1de6394ce7 (qt/qtbase/dev) 9b0ffccabd0bf668b052b0ce74980cc3a0b859e5 (qt/qtbase/6.0) bed37717886721888d87a80911a3403df9ef46c9 (qt/qtbase/6.1) b7c4b74146 (qt/tqtc-qtbase/5.15) b7c4b74146 (qt/tqtc-qtbase/tqtc/vxworks-5.15.10)
Description
I overloaded the QTextObjectInterface class to draw an Object. When the cursor is at the end of the Object, there is an error in the starting position of the cursor drawing, just like the GIF in the attachment.
I overloaded the QTextObjectInterface class to draw an Object. When the cursor is at the end of the Object, there is an error in the starting position of the cursor drawing, just like the GIF in the attachment.
Below is the code for me to insert an Object. Now there is a problem with the cursor position, just like the GIF in the attachment.
void Widget::on_pushButton_clicked(bool checked) { QString text = "123"; QTextCharFormat format; format.setObjectType(TO_ObjectAt); format.setProperty(OP_Text, QVariant::fromValue(text)); format.setProperty(OP_FontSize, QVariant::fromValue(14)); format.setVerticalAlignment(QTextCharFormat::AlignBottom); ui->textEdit->textCursor().insertText(QString(QChar::ObjectReplacementCharacter), format); qDebug() << "insert text object: " << text; }
After analysis, when an error occurs, the Y coordinate of the cursor is -1.5. Because sl.base <base. When si.ascent> 0, base = si.ascent. So sl.base <si.ascent.
si.ascent comes from QTextDocumentLayout::resizeInlineObject. When the alignment is AlignBottom, si.ascent defaults to the height of the Object.The value of si.descent is 0, we should consider this situation when calculating the starting position of the cursor
QTBUG-92468.tar.gz is my test project, click insert to insert Object.
Attachments
Issue Links
- duplicates
-
QTBUG-86823 REG: Blinking cursor leaving an artifact in QTextEdit
- Closed