Use execCommand
with InsertHTML
:
QString html = "<div>Some text</div>";
QString js = QString("document.execCommand('InsertHTML',false,'%1');").arg(html);
webview->page()->mainFrame()->evaluateJavaScript(js);
And if there are single quote characters in the HTML snippet, make sure you quote them with a backslash, since the snippet is injected through a JS string.