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