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. QWebEngineView, allow embedded JavaScript to use window.open

QWebEngineView, allow embedded JavaScript to use window.open

Scheduled Pinned Locked Moved Solved QtWebEngine
qwebenginejavascriptwindow.open
4 Posts 2 Posters 4.9k 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.
  • P Offline
    P Offline
    pmh4514
    wrote on 28 Jul 2016, 19:00 last edited by
    #1

    I am making a QWebEngine based "wrapper" for a pre-existing HTML/JavaScript application.
    (so that I can use the QWebChannel to interface this old HTML/JavaScript application with C++ functionality)

    Basically everything is working well. Except, some bits of functionality on the HTML/JavaScript side use window.open to spawn a URL in a new browser window.

    This doesn't work within the QWebEngine wrapper.

    I found the QWebEngineSettings::JavascriptCanOpenWindows setting and set it to true, but it still doesn't work.

    I'm not surprised really, as what browser would it open? Is there a signal emitted or that I can connect to, when the embedded javascript calls window.open, so that within my Qt side I could launch a new QWebView instance?

    How can this be accomplished?

    Thanks!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 28 Jul 2016, 19:11 last edited by
      #2

      You can do that on two levels. Either subclass QWebEngineView and implement createWindow or a lower level way - subclass QWebEnginePage and implement createWindow.

      P 1 Reply Last reply 29 Jul 2016, 13:37
      0
      • P Offline
        P Offline
        pmh4514
        wrote on 28 Jul 2016, 19:24 last edited by pmh4514
        #3

        EDIT: I subclassed QWebEngine and can see that createWindow does get called -but what next? It only comes with a "type" paramater.. The javascript is calling window.open(url) - so how do I get the URL? Or do I misunderstand something?

        1 Reply Last reply
        0
        • C Chris Kawa
          28 Jul 2016, 19:11

          You can do that on two levels. Either subclass QWebEngineView and implement createWindow or a lower level way - subclass QWebEnginePage and implement createWindow.

          P Offline
          P Offline
          pmh4514
          wrote on 29 Jul 2016, 13:37 last edited by
          #4

          Ok this put me in the right direction, having subclassed both the view and page, and using createWindow and acceptNavigationRequest, I see how this all works now.. Thanks!

          1 Reply Last reply
          0

          1/4

          28 Jul 2016, 19:00

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved