Die Lösung meines Problems ist wahrscheinlich sehr einfach, aber noch nicht aus meinem Verständnis. Ich versuche, eine HTML-Datei in ein QWebEngineView mit PyQt5 zu laden. So wie ich es tue, ist:HTML-Datei kann nicht mit QWebEngineView.setHtml() geladen werden
self.webView = QtWebEngineWidgets.QWebEngineView(self.splitter)
html = r"C:\DATI\git\webgis\map.html"
self.webView.setHtml(html)
Das einzige, was ich ein String ist, den Pfad und den Namen meiner HTML-Datei darstellt:
C: \ DATI \ git \ WebGIS \ Karte. html
Mein map.html sieht wie folgt aus:
<html>
<head>
<title>Simple Map</title>
<link rel="stylesheet" href="https://openlayers.org/en/v4.5.0/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src="https://openlayers.org/en/v4.5.0/build/ol.js"></script>
<script src=".js/qwebchannel.js"></script>
<style>
body { padding: 0; margin: 0; }
html, body, #map { height: 100%; }
</style>
</head>
<body>
<div id="map" class="map"></div>
<script src="./js/map.js"></script>
</body>
</html>
Seltsam (für mich zumindest), wenn ich self.webView.setHtml("<html><head></head><body><h1>ciao</h1></body></html>")
mache, wird dies den HTML-Code richtig darstellen.
Was fehlt mir?