Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Qt5 QML QtWebKit 3.0 NO javaScriptWindowObjects ?
Forum Updated to NodeBB v4.3 + New Features

Qt5 QML QtWebKit 3.0 NO javaScriptWindowObjects ?

Scheduled Pinned Locked Moved Qt WebKit
5 Posts 3 Posters 10.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pythoneer
    wrote on last edited by
    #1

    Hi i recently changed from qt4 to qt5. Now i wonder if this functionality is implemented in the new qtwebkit 3.0? I looked at the API [http://doc-snapshot.qt-project.org/5.0/qtwebkit/qml-qtwebkit3-webview.html] and there is an incredible decrease of available properties especially the one i am searching for.

    Any ideas how i can add new javascript objects to the webview in qtwebkit 3.0?

    regards

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tomma
      wrote on last edited by
      #2

      Currently it requires using "QtWebKit.experimental 1.0" and there is no javaScriptWindowObjects. Communicating needs to be handled using method experimental.postMessage and signal experimental.onMessageReceived.
      There seems to be also evaluateJavaScript method and property named userScripts.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pythoneer
        wrote on last edited by
        #3

        Thx, for the quick answer.
        The earliest possibly to check this out is Thursday to give feedback. May i ask you where you get this information? I don't wanna come here with every stupid question, if i can simply read about that.

        regards

        1 Reply Last reply
        0
        • P Offline
          P Offline
          pythoneer
          wrote on last edited by
          #4

          Just for the record, if someone has the need for it.

          @import QtQuick 2.0
          import QtWebKit 3.0
          import QtWebKit.experimental 1.0

          Rectangle {

          width: 1024
          height: 768

          WebView{
          url: "http://localhost"
          anchors.fill: parent

             experimental.preferences.navigatorQtObjectEnabled: true
             experimental.onMessageReceived: {
          
                 console.debug("get msg from javascript")
                 experimental.postMessage("HELLO")
             }
          

          } // webview
          } // rectanlge@

          altered it to get it through the forum parser :)

          @<html>
          <body>
          <h1>It just works!</h1>

          <p>Play with me...</p>

          <button o n c l c i k="nativecall();">test</button>
          <div id="out"></div>

          <s r c p i t t p y e="t x e t / j a v s a c i r p t ">
          function nativecall(){
          console.log("will try native call");
          var elem = document.getElementById("out"). inner H t M l ="clicked";
          navigator.qt.postMessage('this is a js call');
          }

          function jsCall(message){
              var elem = document.getElementById("out"). inner H t M l ="and the other way around " + message;
          }
          
          navigator.qt.onmessage = function(ev) {
              jsCall(ev.data);
          }
          

          </ script >

          </body>
          </html>@

          1 Reply Last reply
          0
          • E Offline
            E Offline
            ezerek
            wrote on last edited by
            #5

            The cpp to js bridge example here was very useful. thanks.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved