[Interest] Macro support with QTextEdit.
william.crocker at analog.com
william.crocker at analog.com
Mon Jan 11 12:08:16 CET 2016
On 01/10/2016 02:59 AM, Tony Rietwyk wrote:
> 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:
>
The HTML representation is kind of an abomination and ultimately
I would like to have more control, so I just wrote my own XML read/write
code at the cost of ~250 LOC.
Thanks
Bill
> - 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
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
More information about the Interest
mailing list