Cannot get "evaluateJavaScript" to update element in HTML



  • I have a HTML page which shall contain dynamic contents, which looks like this:
    @<html>
    <head>
    <meta charset="utf-8">
    <title>Test</title>
    <style>

      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;
      }
    

    </head>
    <body>
    <ul id="leftMessages" class="messages">
    <li>
    <h1>Titel</h1>
    <h2>Titel</h2>
    <p>Titel</p>
    </li>
    <li>
    <h1>Titel</h1>
    <h2>Titel</h2>
    <p>Titel</p>
    </li>
    </ul>
    </body>
    </html>@

    I have tried to update the contents in the following matter:
    @
    QWebView webView = new QWebView();
    webView->setUrl(/path/to/above/html);
    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.