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. Link Click Not Triggering QWebEnginePage::acceptNavigationRequest()

Link Click Not Triggering QWebEnginePage::acceptNavigationRequest()

Scheduled Pinned Locked Moved Unsolved QtWebEngine
2 Posts 2 Posters 477 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
    JW16
    wrote on last edited by
    #1

    Hello. I am porting from QWebKit (Qt 4.8) to QWebEngine (Qt 5.15). In the application, we set some of our own basic HTML into a view (just some text which contains href links). The link URL is actually just some text which we are using to take a certain action in our desktop application.

    In Qt 4.8, we would set the QWebPage::DelegateAllLinks policy and connect the linkClicked() signal to our own C++ class to take the appropriate action in the application.

    After reading the Qt porting guide and this post, I created my own QWebEnginePage subclass that overrides acceptNavigationRequest() to emit it's own signal on link click action and set it in my QWebEngineView, exactly as described in the post.

    The view/page loads the HTML containing the links after calling setHtml(), but the view goes blank and nothing happens in my application after clicking any link. In the debugger, acceptNavigationRequest() is never triggered on the link click at all! It is only triggered once when loading the HTML via setHtml().

    I would like to understand what Qt is doing as soon as the link is clicked. Does the link click cause another QWebEnginePage to be created and try to load the nonsense URL we are trying to intercept? The solution I've implemented seems to work for others when searching online, so I've come here.

    X 1 Reply Last reply
    1
    • J JW16

      Hello. I am porting from QWebKit (Qt 4.8) to QWebEngine (Qt 5.15). In the application, we set some of our own basic HTML into a view (just some text which contains href links). The link URL is actually just some text which we are using to take a certain action in our desktop application.

      In Qt 4.8, we would set the QWebPage::DelegateAllLinks policy and connect the linkClicked() signal to our own C++ class to take the appropriate action in the application.

      After reading the Qt porting guide and this post, I created my own QWebEnginePage subclass that overrides acceptNavigationRequest() to emit it's own signal on link click action and set it in my QWebEngineView, exactly as described in the post.

      The view/page loads the HTML containing the links after calling setHtml(), but the view goes blank and nothing happens in my application after clicking any link. In the debugger, acceptNavigationRequest() is never triggered on the link click at all! It is only triggered once when loading the HTML via setHtml().

      I would like to understand what Qt is doing as soon as the link is clicked. Does the link click cause another QWebEnginePage to be created and try to load the nonsense URL we are trying to intercept? The solution I've implemented seems to work for others when searching online, so I've come here.

      X Offline
      X Offline
      XuanXuan
      wrote on last edited by
      #2

      Any update on this issue?

      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