I have stored html links in a column of a postgis layer. There are a few entries which have multiple links stored in one cell (blank separated). I have to use the firefox.exe to open the links in multiple tabs. This doesn't work with Open type,

I can open these links with:

"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" [% "link" %] 

An entry of link looks like:


Now I want to use the same column to open the link in this way:


I tried:

"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" [% regexp_replace("link",'goingfurther_[0-9][0-9]_' ,'') %]

"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" regexp_replace([% "link" %],'goingfurther_[0-9][0-9]_' ,'')

But QGIS can't open this. The first replace expression works with the field calculator.

  • 2
    I'm afraid/think you mix a bunch of things together (html, rdbms+gis, geo-data, qgis) which are not desigend for a cooperation in that way. You could consider three components: 1. a web server (generate/delivering html) 2. with gis capabilities (handle the data for positions and links when clicking) and 3. a application logic (the regexp stuff, to get next html page), to do that
    – huckfinn
    Mar 10, 2016 at 9:02
  • There is a Insert Expression button in the Actions Form. So I assumed regex will be an option to create actions.
    – Stefan
    Mar 10, 2016 at 10:09

1 Answer 1


Into the blue untested: Following the instruction in the qgis tutorial it seems, that the call Open file_location/file.type, to start an application like a browser, is connected with the default settings for the mimetype type in your OS. May Open is a wrapper around os.startfile.. for example...

One way to solve the problem could be, to register the application firefox to the content of to text/html.

A second opportunity, you could follow, is shown in paragraph 6.4.5 of the same qgis tutorial. The action statement (here a call to show the internal web componenet QWebView):

from PyQt4.QtCore import QUrl; \
from PyQt4.QtWebKit import QWebView; \
myWV = QWebView(None); \
myWV.load(QUrl('http://wikipedia.org/wiki/[% "name" %]')); \

could be adopted in a pythonish way to start the firefox application.

import os; \
app  = "'C:\\Program Files (x86)\\Mozilla Firefox\firefox.exe' "; \
file = [% regexp_replace("link",'goingfurther_[0-9][0-9]_' ,'') %]; \
os.system(app+" "+file);


import subprocess; \
subprocess.call([app, file]); \

if you have problems with the spaces and quotes.


  1. I add some line breaks to the action code. The sign \ at the end of each line indicates, that the code has to be written in one line in the action field.

  2. The QGIS Application / Map setup works a little bit like a dynamic web application with GIS capabilities. This could be done in a more transparent way but with much more effort.

  • It works, thank you. I have to define file = u'[% regexp_replace("link",'goingfurther_[0-9][0-9]_' ,'') %]' to get it work. Otherwise there is a syntax error due to the link address. Explained here: gis.stackexchange.com/questions/56579/…
    – Stefan
    Apr 28, 2017 at 6:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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