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. Adding objects to Web Worker context
Forum Updated to NodeBB v4.3 + New Features

Adding objects to Web Worker context

Scheduled Pinned Locked Moved Qt WebKit
2 Posts 2 Posters 2.7k 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.
  • F Offline
    F Offline
    fancycode
    wrote on last edited by
    #1

    I'm starting a Web Worker from inside a page which is loaded in a QWebView. While loading, I use the "javaScriptWindowObjectCleared" signal to add custom objects to the frame (using "addToJavaScriptWindowObject"). This works fine for the page initially loaded, but these objects are not available in the Web Worker context and there seems to be no signal that is triggered when the Worker starts.

    Is there a way to get notified about new Web Workers so I can add my objects?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      eikeR
      wrote on last edited by
      #2

      You did not understand how Web Workers work. They have their own context and can never access the DOM or a window object -- well, some say that Web Workers exist in a vacuum. See here:

      "http://www.html5rocks.com/en/tutorials/workers/basics/#toc-enviornment-features":http://www.html5rocks.com/en/tutorials/workers/basics/#toc-enviornment-features

      That behaviour has nothing to do with QtWebKit but is the normal Web Worker specification. An object you add with @addToJavaScriptWindowObject("THIS_GETS_TO_THE_DOM", yourObject)@

      is added to the DOM (where else should it be placed?)! So, no chance that you can access it from within your Web Worker.

      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