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. Links does not open in QWebView
Forum Updated to NodeBB v4.3 + New Features

Links does not open in QWebView

Scheduled Pinned Locked Moved Unsolved Qt WebKit
6 Posts 2 Posters 2.1k 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.
  • V Offline
    V Offline
    voltron
    wrote on last edited by
    #1

    I'm trying to integrate 3rd party web-service into my program. For this I use QWebView which opens a page with some JS code. Page loads fine, but when I click on any link nothing happens and there is no indication what is wrong.

    Here is test code

    import os
    import sys
    
    from PyQt5.QtCore import QUrl
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtWebKit import QWebSettings
    from PyQt5.QtWebKitWidgets import QWebView, QWebInspector, QWebPage
    
    app = QApplication(sys.argv)
    webView = QWebView()
    QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
    QWebSettings.globalSettings().setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True)
    webView.page().settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
    inspector = QWebInspector()
    inspector.setPage(webView.page())
    
    content = ''
    with open(os.path.join(os.path.dirname(__file__), 'index.html'), 'rb') as f:
        content = f.read()
    
    webView.setContent(content)
    webView.show()
    app.exec_()
    

    And here is HTML I'm using

    <html>
      <head>
        <script type="text/javascript" src="https://cdn.3dmapping.cloud/18.1.4/javascript/orbitgt_3dm_sdk.js"></script>
      </head>
    
      <body >
        <div id="app">
    
        <script type="text/javascript">
          var viewer;
    
          function handleReady() {
            viewer.setSize(600,400);
          }
    
          function handleDOMReady() {
            var applicationName = "test app";
            var appElement = document.getElementById("m3dviewer");
            viewer = new orbitgt.mapping3d.sdk.viewer.SDKViewer(applicationName, appElement);
            viewer.isReady.then(handleReady);
          }
    
          document.addEventListener("DOMContentLoaded", handleDOMReady);
        </script>
    
        <div id="m3dviewer"/>
      </body>
    </html>
    

    I'm on Linux, Qt version is 5.9.5 and Python 3.6.5

    1 Reply Last reply
    0
    • V Offline
      V Offline
      voltron
      wrote on last edited by
      #2

      Hmm, seems this is because QtWebkit lacks support of some JS features (not fully compliant with ECMA?). Can anyone confirm?

      Maybe there are some workarounds or list of unsupported JS features?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Konstantin Tokarev
        wrote on last edited by
        #3

        You need to use QtWebKit 5.212 to get more supported JS features

        V 1 Reply Last reply
        1
        • K Konstantin Tokarev

          You need to use QtWebKit 5.212 to get more supported JS features

          V Offline
          V Offline
          voltron
          wrote on last edited by
          #4

          @Konstantin-Tokarev how I can check QtWebKit version?

          In my system I have libqt5webkit5-dev package installed at its version is
          5.212.0~alpha2-7ubuntu1. I assume this is the most recent version from your fork.

          Also I checked WebKit version with the following code

          >>> from PyQt5.QtWebKit import qWebKitVersion
          >>> print(qWebKitVersion())
          602.1
          

          Are there newest version?

          K 1 Reply Last reply
          0
          • V voltron

            @Konstantin-Tokarev how I can check QtWebKit version?

            In my system I have libqt5webkit5-dev package installed at its version is
            5.212.0~alpha2-7ubuntu1. I assume this is the most recent version from your fork.

            Also I checked WebKit version with the following code

            >>> from PyQt5.QtWebKit import qWebKitVersion
            >>> print(qWebKitVersion())
            602.1
            

            Are there newest version?

            K Offline
            K Offline
            Konstantin Tokarev
            wrote on last edited by
            #5

            @voltron No, that's what I was suggesting to you. Could you specify what JS features are you lacking?

            V 1 Reply Last reply
            0
            • K Konstantin Tokarev

              @voltron No, that's what I was suggesting to you. Could you specify what JS features are you lacking?

              V Offline
              V Offline
              voltron
              wrote on last edited by
              #6

              @Konstantin-Tokarev I'm afraid no, I'm not a JS dev. The problem is that JS code I posted in the first message does not work with errors

              https://cdn.3dmapping.cloud/18.1.4/javascript/orbitgt_3dm_sdk.js line
              1: TypeError: a.call is not a function. (In 'a.call(this,t,e,n,r)',
              'a.call' is an instance of ProxyObject)
              

              I was able to identify that calls Array.from() and Object.assign() are missed, but maybe there are more.

              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