Embedding hidden information in a QTextDocument



  • I need to add hidden information to a document. More specifically, the user should be able to add certain text blocks that contain specific information that can be changed and updated later on. A good example would be the current date or a multi-lingual text block (which displays a specific information in the currently selected language).

    I have found a similar question here:
    "Hidden information in a QTextDocument":http://qt-project.org/forums/viewthread/3428

    The last post was particularly interesting:

    [quote author="Volker" date="1296040209"]There are no means to leave comments or hidden text in a text document. You would have to subclass QTextDocument and/or QTextEdit an put that information into the output generated by that manually. You will have to parse it out of a to-be-set document manually too, as QTextDocument discards all data it is not supposed to use (ie. feeding your manually crafted text into a regular QTextDocument "cleans" out all the added data).[/quote]

    Now I found that the supported HTML subset includes the "meta" tag, which sounds exactly like what I need. But it seems that even this supported tag is scrubbed when setting the html to the text document.

    As for subclassing QTextDocument: The destructor is not virtual. Not good for subclassing.

    Any ideas?



  • [quote author="Asperamanca" date="1341996951"]As for subclassing QTextDocument: The destructor is not virtual. Not good for subclassing.

    Any ideas?[/quote]

    At least on this issue: the destructor is virtual. QTextDocument is a [[doc:QObject]], and QObject has a virtual destructor. So, no issues there. I don't know enough about QTextDocument to comment on your actual question, sorry.



  • My fault, I looked up the destructor for QTextDocument without checking the base class.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.