Dear QGIS Developers,
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.
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).
I've found numerous unresolved discussions about QtWebEngine online, but
they haven't helped me achieve my goal.
Here is my current setup:
* Windows 10
* Standard QGIS installation (not OSGeo4W), version: 3.36.3-Maidenhead
* PyQt version: 5.15.10
* Qt version: 5.15.13
Progress so far:
1. 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.
2. 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:
python -m pip install PyQtWebEngine
Then, using
pip list
I confirmed the dependencies are now:
PyQtWebEngine 5.15.6
PyQtWebEngine-Qt5 5.15.2
3. At this point, I was able to write the following Python code and receive
a positive output
try:
from PyQt5.QtWebEngineWidgets import QWebEngineView,
QWebEngineProfile, QWebEnginePage, QWebEngineSettings
webengine_available = True
print("QtWebEngine available")
except ImportError as e:
webengine_available = False
print("QtWebEngine not available:", e)
4. 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.
Where I am stuck:
1. Writing from qgis.PyQt.QtWebEngineWidgets results in an error.
2. 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:
if webengine_available:
print("WebEngine is available. Initializing QWebEngineView...")
widget = QWebEngineView()
self.preview = widget
try:
self.preview.setUrl(QUrl("https://opengis.it"))
print("Loading opengis.it in QWebEngineView.")
except Exception as e:
print("Failed to set URL:", e)
else:
print("WebEngine is not available. Initializing QTextBrowser...")
widget = QTextBrowser()
widget.setText(self.tr('Preview is not available since QtWebEngine
dependency is missing on your system'))
print("QTextBrowser initialized with fallback message.")
self.right_layout.insertWidget(0, widget)
print("Widget inserted into right_layout.")
Questions:
1. Since QtWebKit was deprecated in Qt 5.6, why does it still work in
version 5.15.13?
2. Why isn't the QtWebEngine dependency included by default in the .msi
installation?
3. Why doesn't from qgis.PyQt.QtWebEngineWidgets work?
4. 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)?
Current Status:
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.
Thank you all for your valuable work, which allows me to perform my beloved
job.
Best regards
Andrea Ordonselli
OpenGIS.it
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer