[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: PyQt5 QWebEngineView does not show webpage
From:       colin.mcphail () mac ! com
Date:       2022-09-16 12:54:07
Message-ID: D972CA12-06B2-48EE-998A-56492D3EA89F () mac ! com
[Download RAW message or body]

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@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


[Attachment #3 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html; \
charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
line-break: after-white-space;" class="">Hi Jean-Baptiste,<div class=""><br \
class=""></div><div class="">I think that you need to create and execute an \
application object in order to keep the QWebEngineView on screen:</div><div \
class=""><ul class="MailOutline"><li class="">insert the line &nbsp;<font \
face="SFMono-Regular" class="">app = QtWidgets.QApplication( [] )</font> &nbsp;before \
the &nbsp;<font face="SFMono-Regular" class="">dlg = ...</font> &nbsp;line</li><li \
class="">add the line &nbsp; &nbsp;&nbsp;<font face="SFMono-Regular" \
class="">app.exec_()</font> &nbsp;at the end of your example</li></ul><div \
class=""><br class=""></div><div>Hope this helps.</div><div><br \
class=""></div><div>--</div><div>Colin</div><div><br class=""><blockquote type="cite" \
class=""><div class="">On 16 Sep 2022, at 10:03, Jean-Baptiste Peter &lt;<a \
href="mailto:jbpeter@outlook.com" class="">jbpeter@outlook.com</a>&gt; \
wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" \
class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, \
0); font-family: Verdana; font-size: 13px; font-style: normal; font-variant-caps: \
normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: \
0px; text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0in; \
font-size: 11pt; font-family: Calibri, sans-serif;" class="">Hi,<o:p \
class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, \
sans-serif;" class=""><o:p class="">&nbsp;</o:p></div><div style="margin: 0in; \
font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" \
class="">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().<span class="Apple-converted-space">&nbsp;</span><o:p \
class=""></o:p></span></div><div style="margin: 0in; font-size: 11pt; font-family: \
Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p \
class="">&nbsp;</o:p></span></div><div style="margin: 0in; font-size: 11pt; \
font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">I found a few \
post describing a similar issue but didn't find any solution as of now:<o:p \
class=""></o:p></span></div><div style="margin: 0in; font-size: 11pt; font-family: \
Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p \
class="">&nbsp;</o:p></span></div><div style="margin: 0in; font-size: 11pt; \
font-family: Calibri, sans-serif;" class=""><a \
href="https://stackoverflow.com/questions/55252584/pyqt5-qwebengineview-window-wont-show" \
style="color: rgb(5, 99, 193); text-decoration: underline;" class=""><span \
lang="EN-US" class="">https://stackoverflow.com/questions/55252584/pyqt5-qwebengineview-window-wont-show</span></a><span \
lang="EN-US" class=""><o:p class=""></o:p></span></div><div style="margin: 0in; \
font-size: 11pt; font-family: Calibri, sans-serif;" class=""><a \
href="https://stackoverflow.com/questions/72346850/pyqt5-qwebengineview-does-not-show-webpage" \
style="color: rgb(5, 99, 193); text-decoration: underline;" \
class="">https://stackoverflow.com/questions/72346850/pyqt5-qwebengineview-does-not-show-webpage</a><o:p \
class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, \
sans-serif;" class=""><a \
href="https://stackoverflow.com/questions/72131093/pyqt5-qwebengineview-doesnt-load-url" \
style="color: rgb(5, 99, 193); text-decoration: underline;" \
class="">https://stackoverflow.com/questions/72131093/pyqt5-qwebengineview-doesnt-load-url</a><o:p \
class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, \
sans-serif;" class=""><a \
href="https://stackoverflow.com/questions/70988870/unable-to-render-webpage-using-qwebengineview" \
style="color: rgb(5, 99, 193); text-decoration: underline;" \
class="">https://stackoverflow.com/questions/70988870/unable-to-render-webpage-using-qwebengineview</a><o:p \
class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, \
sans-serif;" class=""><o:p class="">&nbsp;</o:p></div><div style="margin: 0in; \
font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p \
class="">&nbsp;</o:p></div><div style="margin: 0in; font-size: 11pt; font-family: \
Calibri, sans-serif;" class="">Here is my script&nbsp;:<o:p class=""></o:p></div><div \
style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p \
class="">&nbsp;</o:p></div><div style="margin: 0in 0in 0in 35.4pt; font-size: 11pt; \
font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">from \
PyQt5.QtWebEngineWidgets import QWebEngineView<o:p class=""></o:p></span></div><div \
style="margin: 0in 0in 0in 35.4pt; font-size: 11pt; font-family: Calibri, \
sans-serif;" class=""><span lang="EN-US" class="">from PyQt5 import QtWidgets<o:p \
class=""></o:p></span></div><div style="margin: 0in 0in 0in 35.4pt; font-size: 11pt; \
font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">from \
PyQt5.QtCore import QUrl<o:p class=""></o:p></span></div><div style="margin: 0in 0in \
0in 35.4pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span \
lang="EN-US" class="">dlg = QtWidgets.QDialog()<o:p class=""></o:p></span></div><div \
style="margin: 0in 0in 0in 35.4pt; font-size: 11pt; font-family: Calibri, \
sans-serif;" class=""><span lang="EN-US" class="">view = QWebEngineView()<o:p \
class=""></o:p></span></div><div style="margin: 0in 0in 0in 35.4pt; font-size: 11pt; \
font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">layout = \
QtWidgets.QHBoxLayout()<o:p class=""></o:p></span></div><div style="margin: 0in 0in \
0in 35.4pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span \
lang="EN-US" class="">layout.setContentsMargins(0, 0, 0, 0)<o:p \
class=""></o:p></span></div><div style="margin: 0in 0in 0in 35.4pt; font-size: 11pt; \
font-family: Calibri, sans-serif;" class=""><span lang="EN-US" \
class="">layout.addWidget(view)<o:p class=""></o:p></span></div><div style="margin: \
0in 0in 0in 35.4pt; font-size: 11pt; font-family: Calibri, sans-serif;" \
class=""><span lang="EN-US" class="">dlg.setLayout(layout)<o:p \
class=""></o:p></span></div><div style="margin: 0in 0in 0in 35.4pt; font-size: 11pt; \
font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">url = \
QUrl("<a href="https://www.whatsmybrowser.org/" style="color: rgb(5, 99, 193); \
text-decoration: underline;" class="">https://www.whatsmybrowser.org/</a>")<o:p \
class=""></o:p></span></div><div style="margin: 0in 0in 0in 35.4pt; font-size: 11pt; \
font-family: Calibri, sans-serif;" class=""><span lang="EN-US" \
class="">view.load(url)<o:p class=""></o:p></span></div><div style="margin: 0in 0in \
0in 35.4pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span \
lang="EN-US" class="">dlg.show()<o:p class=""></o:p></span></div><div style="margin: \
0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" \
class=""><o:p class="">&nbsp;</o:p></span></div><div style="margin: 0in; font-size: \
11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">My \
configuration:<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0in \
35.4pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span \
lang="EN-US" class="">Windows 11<o:p class=""></o:p></span></div><div style="margin: \
0in 0in 0in 35.4pt; font-size: 11pt; font-family: Calibri, sans-serif;" \
class=""><span lang="EN-US" class="">PyQt5 5.15.4<o:p \
class=""></o:p></span></div><div style="margin: 0in 0in 0in 35.4pt; font-size: 11pt; \
font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">PyQt5-sip \
12.9.0<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0in 35.4pt; \
font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" \
class="">PyQtWebEngine 5.15.5<o:p class=""></o:p></span></div><div style="margin: \
0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" \
class=""><o:p class="">&nbsp;</o:p></span></div><div style="margin: 0in; font-size: \
11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p \
class="">&nbsp;</o:p></span></div><div style="margin: 0in; font-size: 11pt; \
font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Do you have \
any idea what could be the problem? Thank you,<o:p class=""></o:p></span></div><div \
style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" \
class=""><span lang="EN-US" class=""><o:p class="">&nbsp;</o:p></span></div><div \
style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" \
class=""><span lang="EN-US" class="">Best,<o:p class=""></o:p></span></div><div \
style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" \
class=""><span lang="EN-US" class=""><o:p class="">&nbsp;</o:p></span></div><div \
style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" \
class=""><span lang="EN-US" class=""><o:p class="">&nbsp;</o:p></span></div><div \
style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" \
class=""><span lang="EN-US" style="font-size: 10pt; font-family: &quot;Source Sans \
Pro&quot;, sans-serif;" class="">--<o:p class=""></o:p></span></div><div \
style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b \
class=""><span style="font-size: 10pt; font-family: &quot;Source Sans Pro&quot;, \
sans-serif;" class="">Jean-Baptiste \
PETER</span></b></div></div></div></blockquote></div><br \
class=""></div></body></html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic