Overriding acceptNavigationRequest

Heads up! You've already completed this tutorial.

Han | 2021-03-09 23:26:07 UTC | #1

https://pastebin.com/Fwe1bz4z

Hi, I wrote a minimum viable program demonstrating how to override acceptNavigationRequest. I used this tutorial as a guide, which was immensely helpful in learning how to do this.

I was able to successfully demonstrate what I was hoping to do in one particular way. However, to do so you have to open a URL to a local resource to make the program work. See line 25, which use the method load.

I tried the setHtml method on line 23, which is currently commented out. However, when I commented out line 25 in favor of line 23, the program doesn't work. CustomPage's acceptNavigationRequest's code was no longer triggered, and instead the program tries to take me to a new page, which I prohibited in the acceptNavigationRequest method I wrote. I don't know why this way doesn't work, and it may be crucial to the project I am working on. I feel that I need to use .toHtml when translating markdown into something that the program can render.

My intent for this program was to learn how to write code that override the QWebEnginePage's default behavior so that I can use the html elements as UI interface rather than as an internal web browser. I don't need the links to go anywhere but internally, maybe with the exception of opening links in an external browser should that be needed.


Packaging Python Applications with PyInstaller by Martin Fitzpatrick — This step-by-step guide walks you through packaging your own Python applications from simple examples to complete installers and signed executables.

More info Get the book

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak

Overriding acceptNavigationRequest was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt.