Re: [Interest] Macro support with QTextEdit.
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 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 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@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Macro support with QTextEdit.
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 tags and replace them with QWidgets: - We fetch all of the text using codecForHtml. - Search for 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@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Macro support with QTextEdit.
How do I this using a QTextEdit widget in HTML mode with QTextCursor etc. Okay. I have made some progress using the QTextObjectInterface. Next series of questions: - If a QTextCursor spans one of my inline objects and some aspect of the font is changed, how does my object get notified. - My object is basically a piece of text. How do I render it on the same base line as neighboring text. Okay. I have made more progress. The object format is obviously provided in the QTextFormat argument passed to the ::intrinsicSize and ::drawObject functions. :-) I also have the text located vertically, but I think it is just a lucky combination of the vertical alignment from the format and how I size and draw the text. I will have to see how far that gets me. Next question: How do I save and restore to HTML? Thanks. Bill ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
Re: [Interest] Macro support with QTextEdit.
On 01/08/2016 05:40 PM, Bill Crocker wrote: Hello: I am working on a WYSIWYG editor. The user needs to be able to enter macros which render specially on the screen. For the purpose of this conversation, pretend they enter "$DATE" which displays as "8-JAN" on the screen. They are not allowed to edit the "8-JAN" directly. If they act to edit the "8-JAN", a widow would pop up where they can edit the "$DATE". If they changed it to "$YEAR", "2016" would appear in the screen when they are done. These macros would be interspersed with regular text. How do I this using a QTextEdit widget in HTML mode with QTextCursor etc. Okay. I have made some progress using the QTextObjectInterface. Next series of questions: - If a QTextCursor spans one of my inline objects and some aspect of the font is changed, how does my object get notified. - My object is basically a piece of text. How do I render it on the same base line as neighboring text. Thanks. Bill Thanks. Bill ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
[Interest] Macro support with QTextEdit.
Hello: I am working on a WYSIWYG editor. The user needs to be able to enter macros which render specially on the screen. For the purpose of this conversation, pretend they enter "$DATE" which displays as "8-JAN" on the screen. They are not allowed to edit the "8-JAN" directly. If they act to edit the "8-JAN", a widow would pop up where they can edit the "$DATE". If they changed it to "$YEAR", "2016" would appear in the screen when they are done. These macros would be interspersed with regular text. How do I this using a QTextEdit widget in HTML mode with QTextCursor etc. Thanks. Bill ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest