Important: Please read the Qt Code of Conduct -

Cannot get "evaluateJavaScript" to update element in HTML

  • I have a HTML page which shall contain dynamic contents, which looks like this:
    <meta charset="utf-8">

      body, html, ul {
        margin: 0;
        padding: 0;
        font-family: 'trebuchet ms', helvetica, arial, sans-serif, verdana;

    background: transparent;

      #leftMessages {
        position: absolute;
        top: 0;
        left: 0;
        width: 20%;
      .messages {
        padding: 0 20px;
      .messages li {
        background: rgba(0,0,0,0.75);
        border-radius: 10px;
        color: #fff;
        margin: 8px 0;
        padding: 5px 20px;

    <ul id="leftMessages" class="messages">

    I have tried to update the contents in the following matter:
    QWebView webView = new QWebView();
    webView->page()->mainFrame()->evaluateJavaScript("document.getElementById("leftMessages"). innerHTML = "<li>This is a test</li>";");

    The HTML is shown but I am not able to update any of the elements - they just have the default values as set in th e HTML file.

    So my question is, how do I update my HTML file from Qt? The above procedure doesn't work.

    Thanks and regards.

  • Maybe you can get an answer on assistant with searching "The QtWebKit Bridge"

Log in to reply