Append content to QWebView
Hello,
I search for a way to append content to a QWebView, like the way it is possible with QTextBrowser::append(), in order to show small html fragments that may contain external content like pictures (gif) or youtube video. Is that possible :confused:
Or should I rather try to do this with QTextBrowser. Then I have the vague idea that I have to add some mime-thing for the file formats to support in oder to load them from external. But I do not have any clue how to achieve that. :(
Regards
Re: Append content to QWebView
Re: Append content to QWebView
Quote:
Originally Posted by
tbscope
I knew setHtml(). With this function I can set the content, but not append() to existing content :(
Re: Append content to QWebView
You can't append to an HTML file because it must end with the </html> tag.
Maybe if you have the current HTML stored somewhere you can remove the </html> tag, append HTML code, and then append "</html>"?
Re: Append content to QWebView
Quote:
Originally Posted by
MTK358
You can't append to an HTML file because it must end with the </html> tag.
Maybe if you have the current HTML stored somewhere you can remove the </html> tag, append HTML code, and then append "</html>"?
I hoped QWebView would provide something like that.
Now I have decided to write my own class, derived from QWebView, storing the content in local QString member variable and setting the content after change in QWebView. The should be very easy ;-)
However, I would like to make shure that the resulting document is a vaild html format. Can someone suggest an small and lightwight (free) html checker, available as library or source?
Re: Append content to QWebView
You can do it using the easy way:
webView->page()->mainFrame()->evaluateJavaScript("document.body.innerHTML += [your code]");
Using scripts you can dynamically "talk" with the HTML DOM.
in the [your code] i'm using a "window.bridge.code" with addToJavaScriptWindowObject.
But you can simples put your text there, or use "document.body.innerHTML += '" + code + "';";
^^
Re: Append content to QWebView
Quote:
Originally Posted by
tbscope
He's asking for append, not for set