Important: Please read the Qt Code of Conduct -

Links does not open in QWebView

  • 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), True)
    inspector = QWebInspector()
    content = ''
    with open(os.path.join(os.path.dirname(__file__), 'index.html'), 'rb') as f:
        content =

    And here is HTML I'm using

        <script type="text/javascript" src=""></script>
      <body >
        <div id="app">
        <script type="text/javascript">
          var viewer;
          function handleReady() {
          function handleDOMReady() {
            var applicationName = "test app";
            var appElement = document.getElementById("m3dviewer");
            viewer = new orbitgt.mapping3d.sdk.viewer.SDKViewer(applicationName, appElement);
          document.addEventListener("DOMContentLoaded", handleDOMReady);
        <div id="m3dviewer"/>

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

  • 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?

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

  • @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())

    Are there newest version?

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

  • @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 line
    1: TypeError: is not a function. (In ',t,e,n,r)',
    '' is an instance of ProxyObject)

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

Log in to reply