PDA

View Full Version : QTextEdit::toHtml() - get clear html



folibis
25th November 2013, 03:55
I use QTextEdit as HTML editor for templates in my application.
So, when I save resulted HTML structure via toHtml() I get string looked like a garbage. QTextEdit inserts style to every tag. for example if I press enter new paragraph looks like

<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Some text</p>
There is sence to add style to formatted text, for example, if I set text to "bold", result looks like

<p style=" font-weight:600;">Bolded text</p>
but for what it inserts styles to paragraph without format?
So my question - is there way to get "clean" HTML, without unwanted styles?

folibis
25th November 2013, 23:52
I've solved the problem.
QTextEdit totally useless to edit HTML (limited HTML tags set, no external css files etc.) so I switched to WebKit (QWebView)
Good example - https://qt.gitorious.org/qt-labs/graphics-dojo/source/8000ca3b229344ed2ba2ae81ed5ebaee86e9d63a:htmledito r