[webkit-qt] Could QWebFrame generate simple HTML code?

Coda Highland chighland at gmail.com
Tue Aug 14 06:50:20 PDT 2012

On Tue, Aug 14, 2012 at 12:29 AM, 程梁 <chengliang.soft at gmail.com> wrote:
> Hey, I'm trying to develop a WYSIWYG HTML editor based on QtWebkit, but
> nowadays
> I found a problem:
> The HTML source code generated by QWebFrame::toHtml() is rather complex,
> for example, it will add style to <body /> which is not necessary. Could I
> generate
> the HTML source code by myself? If I use QTextEdit, I could loop all text
> blocks and
> try to create source code according to each block. But how could I do the
> same
> with QWebFrame?
> For example, the code I got will be
> "http://www.w3.org/TR/html4/strict.dtd"><html><head>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
> <title>HTML Editor Demo</title>
> </head><body style="word-wrap: break-word; -webkit-nbsp-mode: space;
> -webkit-line-break: after-white-space; ">hey<div>newline</div></body></html>
> in which I just write hey and I want to get
> <p>hey</p>
> <p>newline</p>
> as simple.
> The problem is the first line's code is without any tags and the second line
> is warpped with <div>
> which <p> should be better.
> How could I solve this problem? Thank you!

evaluateJavaScript("return document.body.innerHTML"); maybe?

/s/ Adam

More information about the webkit-qt mailing list