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. Signal when QWebEngineView or its page have completed execution of page JavaScripts?
Qt 6.11 is out! See what's new in the release blog

Signal when QWebEngineView or its page have completed execution of page JavaScripts?

Scheduled Pinned Locked Moved Unsolved QtWebEngine
3 Posts 2 Posters 2.4k 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.
  • J Offline
    J Offline
    jofo
    wrote on last edited by
    #1

    I am exploring using QWebEngineView to render a particular webpage that contains some JavaScript that alter the page's DOM. When fully rendered I want to print the page. The page loads just fine and the javascripts executes automatically.

    I can use the loadFinished() signal to tell when the page is loaded, but I wonder if there is a way to tell when also the javascript has been fully executed?

    I am currently using Qt 5.8 and the minimal webenginewidget example as a base.

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

      There is no such thing as "the java-script has been fully executed".
      If you don't think so - please define when "the java-script has been fully executed"

      • there are many script languages (not just java-script)
        https://www.w3.org/TR/html4/interact/scripts.html

      • there are many java-script scripts on a single page

      • what if one of the scripts has infinite loop (playing video or background audio etc.)

      That's why we have to do with loadFinished() only at least that's a known event. One possible workaround is (if java-script modifies DOM to wait for these modifications to appear - try to detect using XPath/CSS and then emit your own signal)
      NB! Due to its asynchronous nature there is no guarantee that's the last script executed!

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jofo
        wrote on last edited by
        #3

        Thanks for the informative points. What I had in mind, that potentially could define "fully executed" is that the script interpreter, in case there are no infinite loops etc, has reached the last line of code for all (or each) scripts on the page. But as you point out that might be a bit naive.

        In my case I do have control over the page to be rendered, so having a hidden DOM element saying "done", or changing the title for which there is a signal already, would work.

        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