Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Inject script on all subframes with callback
Qt 6.12 LTS is out! See what's new in the release blog

Inject script on all subframes with callback

Scheduled Pinned Locked Moved Unsolved QtWebEngine
1 Posts 1 Posters 683 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.
  • R Offline
    R Offline
    raduc
    wrote on last edited by
    #1

    Hi all!

    I need to inject a script that will run on all the subframes of the page, but also be able to get the result in a callback. I also don't have access to the page before it is created, so in 99.99% of the time my injected script will be injected after the page has fully loaded.

    The QWebEnginePage::runJavaScript method is perfect, but it only runs in the main frame.

    The only method I found for a script to run in all subframes is to use an QWebEngineScript and insert it in the QWebEnginePage::scripts(). There are two issues with this, as far as I tested:

    1. If I insert it after the page loads, the script is never run
    2. It doesn't provide support for callbacks. The only solution to this I have found is QWebChannel. I'd wish to avoid that at all costs, but can't go into details about why. In worst case scenario I will use webchannels if I can get over pt. 1

    So my question is: how can I inject a script into a page after it loads and have it execute in all subframes?
    Thanks!

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