Qt 6.11 is out! See what's new in the release
blog
PyQt6 QWebEngineView unintended content replacement with index of location
-
I'm working on a notetaking tool where notes are written in Markdown and then displayed in HTML via QWebEngineView using a template HTML file.
I've run into a problem where, after being successfully displayed for a split second, the view's contents are replaced by something saying 'Index of LOCATION', followed by a horizontal line and a row of nonfunctional links titled Name, Size, Date, and Modified. I presume this is some kind of blank directory index.
This is the relevant code that I'm using to display individual note pages:
def readPageNew(path): markdownPage = Path(path).read_text() htmlTemplate = Path(f'{openNotebook}/templates/Main.html').read_text() htmlPage = convertToHTML(markdownPage) htmlPage = re.sub(r'\<main\>(.|\n)*\<\/main\>', f'<main>\n{htmlPage}</main>', htmlTemplate, flags=re.MULTILINE) contentDirectory = QUrl.fromLocalFile(f'{openNotebook}/') window.viewPanel.setHtml(htmlPage, baseUrl=contentDirectory)How can I fix this so the contents are never replaced after I explicitly set them?