PyQt5 QWebEngineView does not show webpage

colin.mcphail at mac.com colin.mcphail at mac.com
Fri Sep 16 13:54:07 BST 2022


Hi Jean-Baptiste,

I think that you need to create and execute an application object in order to keep the QWebEngineView on screen:
insert the line  app = QtWidgets.QApplication( [] )  before the  dlg = ...  line
add the line     app.exec_()  at the end of your example

Hope this helps.

--
Colin

> On 16 Sep 2022, at 10:03, Jean-Baptiste Peter <jbpeter at outlook.com> wrote:
> 
> Hi,
>  
> I wrote small script which creates a qwebengineview in a qdialog. When I run it, there is a white flash and then the dialog looks completely empty. The webengineview seems to be initialized as it is possible to call its methods such as .url(). 
>  
> I found a few post describing a similar issue but didn’t find any solution as of now:
>  
> https://stackoverflow.com/questions/55252584/pyqt5-qwebengineview-window-wont-show <https://stackoverflow.com/questions/55252584/pyqt5-qwebengineview-window-wont-show>
> https://stackoverflow.com/questions/72346850/pyqt5-qwebengineview-does-not-show-webpage <https://stackoverflow.com/questions/72346850/pyqt5-qwebengineview-does-not-show-webpage>
> https://stackoverflow.com/questions/72131093/pyqt5-qwebengineview-doesnt-load-url <https://stackoverflow.com/questions/72131093/pyqt5-qwebengineview-doesnt-load-url>
> https://stackoverflow.com/questions/70988870/unable-to-render-webpage-using-qwebengineview <https://stackoverflow.com/questions/70988870/unable-to-render-webpage-using-qwebengineview>
>  
>  
> Here is my script :
>  
> from PyQt5.QtWebEngineWidgets import QWebEngineView
> from PyQt5 import QtWidgets
> from PyQt5.QtCore import QUrl
> dlg = QtWidgets.QDialog()
> view = QWebEngineView()
> layout = QtWidgets.QHBoxLayout()
> layout.setContentsMargins(0, 0, 0, 0)
> layout.addWidget(view)
> dlg.setLayout(layout)
> url = QUrl(“https://www.whatsmybrowser.org/ <https://www.whatsmybrowser.org/>”)
> view.load(url)
> dlg.show()
>  
> My configuration:
> Windows 11
> PyQt5 5.15.4
> PyQt5-sip 12.9.0
> PyQtWebEngine 5.15.5
>  
>  
> Do you have any idea what could be the problem? Thank you,
>  
> Best,
>  
>  
> --
> Jean-Baptiste PETER

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220916/96c7a11d/attachment.htm>


More information about the PyQt mailing list