Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-55039

qt webchannel is deleted on page reload

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • 5.7.1
    • 5.7.0
    • WebChannel, WebEngine
    • None
    • linux, x64 but likely present on all OSes

    Description

      The qt object placed in the global Javascript namespace is deleted when the page is reloaded, or a new page is loaded in an existing QWebEngineView.

      This is a regression from previous Qt releases (IIRC the last version I tested on was 5.5)

      Simply PyQt script to replicate

      from PyQt5.Qt import QApplication, QWebEngineView, QTimer, QWebChannel
      app = QApplication([])
      v = QWebEngineView()
      c = QWebChannel()
      v.page().setWebChannel(c)
      v.setHtml('<script>alert("qt is: " + window.qt)</script>')
      v.show()
      QTimer.singleShot(1000, v.reload)
      app.exec_()
      

      The first alert shows an existing window.qt the second alert (after the reload) show window.qt is undefined.

      This breaks communication between the web application and the C++ application using QWebChannel.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            milianw Milian Wolff
            kovidgoyal Kovid Goyal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes