[Interest] Macro support with QTextEdit.
Tony Rietwyk
tony at rightsoft.com.au
Sun Jan 10 08:59:37 CET 2016
Bill asked:
> Sent: Sunday, 10 January 2016 1:25 AM
> Next question:
>
> How do I save and restore to HTML?
Hi Bill,
I can't help with the saving. But we display html documents with <object>
tags and replace them with QWidgets:
- We fetch all of the text using codecForHtml.
- Search for <object> tags, parse the arguments and replace the tags with
plain "[[object]]" markers, building up a list of their locations.
- Set the modified html into a QTextBrowser.
- Loop over the locations (in reverse order) and create a widget for each
object, parented by the browser, remove the text and insert the
ObjectReplacementCharacter.
There are lots of painful gotchas to work around - moving the widgets to the
correct location, hiding the widgets until required, rendering with the
correct scale when printing, etc.
The document object interface is pretty stunted - in Qt4 I don't believe
there was a virtual hook into the html saving process to handle the special
characters. I suspect you'll need to modify the Qt sources, or create a
copy of the document, and do the reverse of the steps above.
Good luck!
Tony
More information about the Interest
mailing list