QWebEngineView in PySide6 not loading any page

939 views Asked by At

QWebEngineView shows an empty window, no matter what I try.

This demonstrates the problem in an nutshell:

import sys
from PySide6.QtWidgets import QApplication
from PySide6.QtWebEngineWidgets import QWebEngineView
from PySide6.QtCore import QUrl
app = QApplication(sys.argv)
view = QWebEngineView()
def test1(percent):
    print(percent)
view.loadProgress.connect(test1)
def test2(success):
    print(success)
view.loadFinished.connect(test2)
view.setUrl(QUrl("https://www.google.com"))
view.show()
sys.exit(app.exec())

The output says that the loading proceeds from 0 to 100 percent but fails:

doh set to ""  --  SystemOnly
0
100
False

The same happens for local HTML files and for strings of HTML. System: Windows 10; Python 3.11.6 via Microsoft Store; PySide 6.6.0 and some slightly earlier versions. This seems to be a similar problem im PyQt5 rather than Pyside6. The solution "--no-sandbox" does not seem to work for me.

Addendum 1: Adding this:

def test3(status, code):
    print(status, code, hex(code))
view.renderProcessTerminated.connect(test3)

Results in this output:

doh set to ""  --  SystemOnly
0
RenderProcessTerminationStatus.CrashedTerminationStatus -1073741515 -0x3ffffecb
RenderProcessTerminationStatus.CrashedTerminationStatus -1073741515 -0x3ffffecb
100
False

Addendum 2: OK, so this means that a .dll file is not found. Actually, I tried before to add the location of the Qt6Web.....dll files to the PATH, but to no avail. I even tried to place copies of them next to the .py file.

Addendum 3: If I can trust the old and rusty Dependency Walker, Qt6WebEngineWidgets.dll requires several dozen of DLLs such as api-ms-win-core-url-l1-1-0.dll, which cannot be found (says Dependency Walker). Actually, however, there are several copies of them in the Windows folder.

1

There are 1 answers

1
youyou On

Take a look at these two links :

Long story short : adding these two lines before the start of the app worked for me.

from PySide6.QtQuick import QQuickWindow, QSGRendererInterface
QQuickWindow.setGraphicsApi(QSGRendererInterface.GraphicsApi.OpenGL)

For the doh set to "" -- SystemOnly message, I'm still investigating it. A good starting point would be the C++ code that throws it.