0

I am using a referenced css file in an HTML Frame in a QGIS 3.4.2 layout.

<link rel="stylesheet" type="text/css" href="map.css">

It works great until I have to go and edit the css. When I make the change, and press Refresh HTML, the HTML frame does not use the updated css. If I exit QGIS, and open again...the changes are present.

Is there a way to configure the QGIS project to watch this file? Or manually reload?

  • Maybe you can use embedded CSS (by placing <style> in your <head>) during the development phase? – Stefan Dec 13 '18 at 20:54
1

1. Store the HTML file in a directory and open a command prompt in that directory. Then type:

python -m http.server 8000    # start local server

2. In QGIS enter http://localhost:8000 as the HTML source:

Screenshot of QGIS 3.2 HTML source - URL with https://localhost:8000 entered

Now when you change your CSS and press "Refresh HTML" in QGIS, the style is immediately applied to your HTML frame.

PS.: Tested in QGIS 3.2

1

I figured out one option using a cache busting technique, but that involves editing each HTML Frame when a change is made. It is not much better, since I'd have to touch every HTML Frame Source and I might as well using the <style>tags.

<link rel="stylesheet" type="text/css" href="map.css?version=1.1">

UPDATE
By using a QGIS Expression, I was able to cache bust the CSS whenever the Refresh HTML button was pressed.

<link rel="stylesheet" type="text/css" href="map.css?version=[%to_string(now())%]" > enter image description here

Also submitted a QGIS Feature Request: 20811

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.