<html><head><style id="css_styles" type="text/css"><!--blockquote.cite { margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc }
blockquote.cite2 {margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc; margin-top: 3px; padding-top: 0px; }
a img { border: 0px; }
table { border-collapse: collapse; }
li[style='text-align: center;'], li[style='text-align: center; '], li[style='text-align: right;'], li[style='text-align: right; '] { list-style-position: inside;}
body { font-family: 'Segoe UI'; font-size: 12pt; }
.quote { margin-left: 1em; margin-right: 1em; border-left: 5px #ebebeb solid; padding-left: 0.3em; }
--></style></head><body><div><div id="xb7214deea99b40ee872000a50d168aed"><div>Hi!</div><div><br /></div><div>I have not got access to a system to actually try my answers so some of them are educated speculation, but hopefully they'll help you in the right direction anyway:</div><div><br /></div><div>* Have you tried if the python3-pyqtwebengine package in the OSGeo4W-installer installs the required dependency?</div><div>* (question 1) It's still (while on Qt 5) possible to build QtWebKit from source, as the OSGeo4W-packagers seem to have done for you: <a href="https://download.osgeo.org/osgeo4w/v2/x86_64/release/qt5/qtwebkit/" style="font-size:12pt;">https://download.osgeo.org/osgeo4w/v2/x86_64/release/qt5/qtwebkit/</a></div><div>* (question 2) QtWebEngine is essentially a repackaged and slightly adapted Chromium; the same engine that powers the Chrome browser. That means installing QtWebEngine pulls in almost as much code as installing another browser, the same happens for QtWebKit (which is a repackaging of the WebKit browser engine). So if both would be installed by default then users would essentially get two additional browsers taking up space on their system</div><div>* (question 3) qgis.PyQt does not export everything from PyQt{version}, but only what is specified by QGIS (<a href="https://github.com/qgis/QGIS/blob/final-3_36_3/python/PyQt/CMakeLists.txt" style="font-size:12pt;">https://github.com/qgis/QGIS/blob/final-3_36_3/python/PyQt/CMakeLists.txt</a>). In 3.36 this does not include QtWebEngineWidgets, however in 3.38 it does (which makes me assume that installing QGIS 3.38 through OSGeo4W will also pull in QtWebEngine automatically as you've requested).</div><div><br /></div><div>Regards,</div><div>Jan Dalheimer</div></div></div>
<div style="clear:both"><br /></div>
<div><br /></div>
<div>
<div>------ Original Message ------</div>
<div>From "Andrea Ordonselli via QGIS-Developer" <<a href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>></div>
<div>To <a href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a></div>
<div>Date 2024-07-08 13:55:30</div>
<div>Subject [QGIS-Developer] Transition from QtWebKit to QtWebEngine in qgis2web (QGIS plugin)</div></div><div><br /></div>
<div id="x638ef51ea7d4462"><blockquote cite="SGAZSI$30D172754494A36ADC025D0FF69D7794@opengis.it" type="cite" class="cite2">
<span style="font-family: Arial; font-size: small;" xam-editor-container="true"><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">Dear
QGIS Developers,
<o:p xmlns:o="#unknown"></o:p></span></p><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">I
am currently maintaining the qgis2web plugin and am in the process of phasing
out QtWebKit due to its obsolescence and inability to handle modern code.
<o:p xmlns:o="#unknown"></o:p></span></p><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">qgis2web
utilizes QtWebKit to display its export in a web preview window, which reads
the exported project comprising HTML, JS, and CSS files. Without updating
QtWebKit, I cannot update the third-party libraries used in the export (e.g.,
ol-geocoder, ol-layerswitcher, and many others).
<o:p xmlns:o="#unknown"></o:p></span></p><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">I've
found numerous unresolved discussions about QtWebEngine online, but they
haven't helped me achieve my goal.
<o:p xmlns:o="#unknown"></o:p></span></p><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">Here
is my current setup:
<o:p xmlns:o="#unknown"></o:p></span></p><ul type="disc">
<li class="MsoNormal" style="line-height: normal;"><span style="font-family: Arial, sans-serif;">Windows 10<o:p xmlns:o="#unknown"></o:p></span></li>
<li class="MsoNormal" style="line-height: normal;"><span style="font-family: Arial, sans-serif;">Standard QGIS installation (not OSGeo4W), version: 3.36.3-Maidenhead<o:p xmlns:o="#unknown"></o:p></span></li>
<li class="MsoNormal" style="line-height: normal;"><span style="font-family: Arial, sans-serif;">PyQt version: 5.15.10<o:p xmlns:o="#unknown"></o:p></span></li>
<li class="MsoNormal" style="line-height: normal;"><span style="font-family: Arial, sans-serif;">Qt version: 5.15.13<o:p xmlns:o="#unknown"></o:p></span></li>
</ul><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">Progress
so far:
<o:p xmlns:o="#unknown"></o:p></span></p><ol start="1" style="margin-top:0cm" type="1">
<li class="MsoNormal" style="margin-top: 12pt; margin-bottom: 12pt; line-height: normal;"><span style="font-family: Arial, sans-serif;">Using "Qt Designer," dragging the "QWebEngineView"
element into the plugin design causes the program to freeze. This issue is
resolved after installing the dependency in the next step.
<o:p xmlns:o="#unknown"></o:p></span></li>
<li class="MsoNormal" style="margin-top: 12pt; margin-bottom: 12pt; line-height: normal;"><span style="font-family: Arial, sans-serif;">The standard installation via .msi lacks the QtWebEngine dependency,
so I had to install it manually. This is a significant obstacle: I believe
most QGIS users install the software on Windows using the .msi package, so
I will need to provide a guide or come up with a solution for installation
through the plugin itself. In any case, I installed the dependency by
opening the "OSGeo4W Shell" and running the command:
<br />
<i><br />
python -m pip install PyQtWebEngine<br />
</i><br />
Then, using<br />
<i><br />
pip list<br />
</i><br />
I confirmed the dependencies are now:<br />
<i><br />
PyQtWebEngine 5.15.6<br />
PyQtWebEngine-Qt5 5.15.2</i><o:p xmlns:o="#unknown"></o:p></span></li>
<li class="MsoNormal" style="margin-top: 12pt; margin-bottom: 12pt; line-height: normal;"><span style="font-family: Arial, sans-serif;">At this point, I was able to write the following Python code and
receive a positive output
<br />
<i><br />
try:<br />
from PyQt5.QtWebEngineWidgets import QWebEngineView,
QWebEngineProfile, QWebEnginePage, QWebEngineSettings
<br />
webengine_available = True<br />
print("QtWebEngine available")<br />
except ImportError as e:<br />
webengine_available = False<br />
print("QtWebEngine not available:", e)</i><o:p xmlns:o="#unknown"></o:p></span></li>
<li class="MsoNormal" style="margin-top: 12pt; margin-bottom: 12pt; line-height: normal;"><span style="font-family: Arial, sans-serif;">In "Qt Designer" I can now add the
"QWebEngineView" element without issues, and if I set a website
manually by configuring the URL in the "QWebEngineView" section,
it displays perfectly.
<o:p xmlns:o="#unknown"></o:p></span></li>
</ol><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">Where
I am stuck:
<o:p xmlns:o="#unknown"></o:p></span></p><ol start="1" type="1">
<li class="MsoNormal" style="line-height: normal;"><span style="font-family: Arial, sans-serif;">Writing <i>from qgis.PyQt.QtWebEngineWidgets</i> results in an error.<o:p xmlns:o="#unknown"></o:p></span></li>
<li class="MsoNormal" style="line-height: normal;"><span style="font-family: Arial, sans-serif;">Whether I add the "QWebEngineView" element manually in
"Qt Designer" or via Python, the result is a completely blank
plugin screen. The code I am testing for insertion is as follows:
<br />
<br />
<i>if webengine_available:<br />
print("WebEngine is available. Initializing
QWebEngineView...")
<br />
widget = QWebEngineView()<br />
self.preview = widget<br />
try:<br />
self.preview.setUrl(QUrl("<a href="https://opengis.it">https://opengis.it</a>"))<br />
print("Loading opengis.it in
QWebEngineView.")
<br />
except Exception as e:<br />
print("Failed to set URL:", e)<br />
else:<br />
print("WebEngine is not available. Initializing
QTextBrowser...")
<br />
widget = QTextBrowser()<br />
widget.setText(self.tr('Preview is not available since
QtWebEngine dependency is missing on your system'))
<br />
print("QTextBrowser initialized with fallback
message.")
<br />
<br />
self.right_layout.insertWidget(0, widget)<br />
print("Widget inserted into right_layout.")</i><o:p xmlns:o="#unknown"></o:p></span></li>
</ol><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">Questions:<o:p xmlns:o="#unknown"></o:p></span></p><ol start="1" style="margin-top:0cm" type="1">
<li class="MsoNormal" style="margin-top: 12pt; margin-bottom: 12pt; line-height: normal;"><span style="font-family: Arial, sans-serif;">Since QtWebKit was deprecated in Qt 5.6, why does it still work in
version 5.15.13?
<o:p xmlns:o="#unknown"></o:p></span></li>
<li class="MsoNormal" style="margin-top: 12pt; margin-bottom: 12pt; line-height: normal;"><span style="font-family: Arial, sans-serif;">Why isn't the QtWebEngine dependency included by default in the .msi
installation?
<o:p xmlns:o="#unknown"></o:p></span></li>
<li class="MsoNormal" style="margin-top: 12pt; margin-bottom: 12pt; line-height: normal;"><span style="font-family: Arial, sans-serif;">Why doesn't <i>from qgis.PyQt.QtWebEngineWidgets</i> work?<o:p xmlns:o="#unknown"></o:p></span></li>
<li class="MsoNormal" style="margin-top: 12pt; margin-bottom: 12pt; line-height: normal;"><span style="font-family: Arial, sans-serif;">Why is there a discrepancy between what I see and configure in
"Qt Designer" and what appears when I run the plugin in QGIS
(specifically, a completely blank screen)?
<o:p xmlns:o="#unknown"></o:p></span></li>
</ol><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">Current
Status:
<o:p xmlns:o="#unknown"></o:p></span></p><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">I
have no errors in the QGIS Python console, only positive prints, but I cannot
get past the blank plugin screen when launched in QGIS.
<o:p xmlns:o="#unknown"></o:p></span></p><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">Thank
you all for your valuable work, which allows me to perform my beloved job.
<o:p xmlns:o="#unknown"></o:p></span></p><p class="MsoNormal" style="margin-top:12.0pt;margin-right:0cm;margin-bottom:
12.0pt;margin-left:0cm;line-height:normal
"><span style="font-family: Arial, sans-serif;">Best
regards
</span></p><div data-signature-id="1">
<div class="xam_msg_class">
<span style="font-family: Arial; font-size: small;" xam-editor-container="true">
<div class="xam_msg_class">
<span style="font-family: Arial; font-size: medium;" xam-editor-container="true">
<div class="xam_msg_class">
<span style="font-family: Arial;" xam-editor-container="true"><font size="2">
</font><div class="xam_msg_class" style=""><span style="font-family: Arial;" xam-editor-container="true"><span style="line-height: 115%; font-family: Calibri, sans-serif; color: rgb(0, 89, 179);"><span style="font-size: small;"><b>Andrea Ordonselli</b></span><br style="color: rgb(0, 0, 0); font-family: Arial; font-size: small;" /><div data-signature-id="1" style="color: rgb(0, 0, 0); font-family: Arial; font-size: small;"><div class="xam_msg_class"><span style="font-size: medium;" xam-editor-container="true"><div class="xam_msg_class"><span xam-editor-container="true"><font size="2"></font><div class="xam_msg_class"><span xam-editor-container="true"><b><span style="line-height: 18.4px; font-family: Calibri, sans-serif; color: rgb(0, 89, 179);"><font size="2">OpenGIS.it</font></span></b></span></div></span></div></span></div></div></span></span>
</div>
</span>
</div>
</span>
</div>
</span>
</div>
</div></span></blockquote></div>
</body></html>