Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. QObject registered to QtWebChannel cannot be accessed in javascript world synchronously when used with Qtwebengine

QObject registered to QtWebChannel cannot be accessed in javascript world synchronously when used with Qtwebengine

Scheduled Pinned Locked Moved Unsolved QtWebEngine
3 Posts 3 Posters 1.3k Views
  • 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.
  • S Offline
    S Offline
    sun708
    wrote on last edited by sun708
    #1

    We are planning to use Qt5.7.1 and have some existing applications on qtwebkit which expect to access methods in javascript world synchronously. These are slot methods of QObject registered using addToJavaScriptWindowObject with QWebPage frame.
    When we port to Q5.7.1 these are registered to QtWebChannel object of QWebEnginePage. Now these methods are asynchronous.

    Is there any alternative for this to make these calls synchronous?

    Given that QtWebengine uses chromium and it internally spawns a different process and since these queries happens over IPC may be these are designed as async. But chromium V8 also supports synchronous IPC communication, so is it possible to support this in future if there is no way to acheive this currently?

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

      Well it runs async (you cannot change that) but you can wait until it completes i.e. synchronize using synchronization primitives or e.g. using high level functionality of e.g. QFuture class like QFuture::waitForFinished()

      but remember - preferred way is to do it async i.e. connect QFuture signal to a slot
      https://stackoverflow.com/questions/25393144/blocked-qfuture-result-or-qfuturewatcher-waitforfinished

      of course you could also try other synchronization primitives like mutexes, semaphores etc.
      http://doc.qt.io/qt-5/threads-synchronizing.html

      just remember that waiting (to synchronize) may block your app/main/GUI thread for long periods of time

      1 Reply Last reply
      0
      • S sun708

        We are planning to use Qt5.7.1 and have some existing applications on qtwebkit which expect to access methods in javascript world synchronously. These are slot methods of QObject registered using addToJavaScriptWindowObject with QWebPage frame.
        When we port to Q5.7.1 these are registered to QtWebChannel object of QWebEnginePage. Now these methods are asynchronous.

        Is there any alternative for this to make these calls synchronous?

        Given that QtWebengine uses chromium and it internally spawns a different process and since these queries happens over IPC may be these are designed as async. But chromium V8 also supports synchronous IPC communication, so is it possible to support this in future if there is no way to acheive this currently?

        D Offline
        D Offline
        dscyw
        wrote on last edited by
        #3

        @sun708 So what's your solution finally? It will be appreciated if you can share to us.

        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