certqt
22nd January 2011, 12:28
I am storing some simple rich text (HTML) strings in a database which are input from a QTextEdit widget and using a QDataWidgetMapper.. I need the formatting attributes (bold, italic, underline, bullets) that rich text provides.
Using the default implementation this means that each record stores the whole QTextDocument which is somewhat wasteful, as it probably only contains about 10 or so words of useful text. Given that all entries in the database will use the same DOCTYPE, CSS etc. I would prefer only to store the data between the <BODY> </BODY> tags.
My idea is to subclass QTextEdit and implement a toHtmlBody() (or just reimplement toHtml()) however I haven't found a neat way of pulling just the body from the document.
So far I tried QXmlStreamReader and various regex's I found on the web.
Any ideas are most welcome!
Using the default implementation this means that each record stores the whole QTextDocument which is somewhat wasteful, as it probably only contains about 10 or so words of useful text. Given that all entries in the database will use the same DOCTYPE, CSS etc. I would prefer only to store the data between the <BODY> </BODY> tags.
My idea is to subclass QTextEdit and implement a toHtmlBody() (or just reimplement toHtml()) however I haven't found a neat way of pulling just the body from the document.
So far I tried QXmlStreamReader and various regex's I found on the web.
Any ideas are most welcome!