[Qt4-preview-feedback] markContentsDirty() does not work on a QTextDocument

Yan Shapochnik Shapochniky at seapine.com
Tue Feb 24 19:10:31 CET 2009


Hello,

I have been attempting to paste in some HTML into a QTextEdit. When I paste the HTML in it looks like QTextDocument did not render it properly, because when I save the contents of the QTextEdit to a file and then re-open it, the formatting looks different. I am attaching an example called test.zip (contains an htm file inside).

1.       open the textedit demo project
2.       unzip test.zip and open test.htm in a browser
3.       copy from browser and paste into the textedit from the demo project
4.       save the file as something
5.       open the file (this is where the contents appear different)

I tried to get QTextDocument to respond to markContentsDirty() by calling it for the entire document length, but it does not attempt to reload the QTextDocument contents. As of right now, the workaround is to do something like this after paste:

this->insertHtml(contentsFromPaste);
this->setHtml(this->toHtml());

Debugging the QTextDocument code shows that the private docChangeFrom variable is always -1 and therefore the call to QTextDocumentPrivate::documentChange() always returns.

Is there a proper way of using markContentsDirty() on the QTextDocument or is this simply a bug?

Thanks,
Yan Shapochnik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt4-feedback/attachments/20090224/92595a80/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.zip
Type: application/x-zip-compressed
Size: 1436 bytes
Desc: test.zip
Url : http://lists.qt.nokia.com/pipermail/qt4-feedback/attachments/20090224/92595a80/attachment.bin 


More information about the Qt4-feedback mailing list