Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.7.0 Beta1
-
None
Description
import QtQuick // import QtQuick.Controls Window { id: window width: 1024 height: 600 visible: true title: edit.textDocument.source Flickable { id: flick anchors.fill: parent contentWidth: edit.contentWidth contentHeight: edit.contentHeight clip: true function ensureVisible(r) { if (contentX >= r.x) contentX = r.x; else if (contentX+width <= r.x+r.width) contentX = r.x+r.width-width; if (contentY >= r.y) contentY = r.y; else if (contentY+height <= r.y+r.height) contentY = r.y+r.height-height; } TextEdit { id: edit width: flick.width focus: true wrapMode: TextEdit.Wrap onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) textFormat: Qt.RichText } } Component.onCompleted: edit.textDocument.source = "sth.html" // Component.onCompleted: { // var request = new XMLHttpRequest() // request.open('GET', 'sth.html') // request.onreadystatechange = function(event) { // if (request.readyState === XMLHttpRequest.DONE) // edit.text = request.responseText // } // request.send() // } }
With the XHR approach we usually call setText(); whereas when we set source, the text control gets notified that the cursor moved, like this:
1 QQuickTextControlPrivate::_q_updateCursorPosChanged qquicktextcontrol.cpp 435
2 QQuickTextControl::qt_static_metacall moc_qquicktextcontrol_p.cpp 310
3 QQuickTextControl::qt_metacall moc_qquicktextcontrol_p.cpp 459
4 QMetaObject::metacall qmetaobject.cpp 337
5 doActivate<false> qobject.cpp 4070
6 QMetaObject::activate qobject.cpp 4104
7 QTextDocument::cursorPositionChanged moc_qtextdocument.cpp 516
8 QTextDocumentPrivate::finishEdit qtextdocument_p.cpp 1213
9 QTextDocumentPrivate::endEditBlock qtextdocument_p.cpp 1171
10 QTextDocument::setHtml qtextdocument.cpp 1300
11 QQuickTextDocumentPrivate::load qquicktextdocument.cpp 158
12 QQuickTextDocument::setSource qquicktextdocument.cpp 108
From one side, it makes sense that inserting into an empty document might move to the end of the insertion. But we're meaning to replace the contents, not insert; it's weird to be inconsistent with the XHR method; and if we don't make it consistent, the Text Editor example might need a workaround, which is probably silly.
But on the upside, somehow this behavior makes QTBUG-118636 go away.
Attachments
Issue Links
- relates to
-
QTBUG-118636 Some missing content of the rich text table while displaying HTML file with TextArea
-
- Closed
-