PDA

View Full Version : QTextEdit insert and get html



Qtonimo
30th October 2012, 11:36
Hi,
I want to develop a QTextEdit, which allows the user to do some basic formatting(bold,italic,lists, ...). So the user inserts html tags like <b>text</b> and so on.
After editing, the html should be stored in a database, but if I call toHtml() the output is different (with info about the font and so on. (The docu confirm that)). If I call toPlainText() the tags go away.

Now I want to know I I have the possibility to get the html, the user inserted before...

thank you

ChrisW67
31st October 2012, 03:10
If you are use the QTextEdit::toHtml() then the the text the user typed will be encoded inside the <body> element. Where the user typed in <> characters (and others) they will be encoded in the resulting HTML. Putting that HTML back will give the user the same text you started with.

If you want the raw text the user typed, including the HTML markup as typed, then you probably should consider using a QPlainTextEdit.