I'm trying to demonstrate to my company that we can begin using QGIS in conjunction with (and sometimes even instead of) ArcGIS and MapInfo. I've started setting up some layout templates but have run into a. In Print Composer, is there a way to add the current project path? In ArcGIS, the dynamic text is:

<dyn type="document" property="path"/>

I'd prefer not to have to copy/paste the document path every time I make a map.


To address answer and comments by artwork21 and Nathan W:

I'm using QGIS 2.0.1. I would also like this path to appear to anyone who may need to open the project for editing without modifying their startup.py file.

  • So you mean the current project path? And are you running QGIS 2.0? – Nathan W Dec 16 '13 at 2:48
  • Yes and yes. Please see my edits. – Fezter Dec 16 '13 at 4:16

As I investigated in this answer it seems anywhere you can use the Expression String Builder you can use the @project_folder variable in at least QGIS 2.16.

Other potentially useful variables can be found in the annotated screenshot below.


|improve this answer|||||

I have not tried this, however it looks like you can create your own custom expression functions (python). This custom expression could be displayed within a composer label. A good how to for creating this would be to go through this blog:

Nathan's QGIS Blog - User defined expression functions for QGIS

Within your function you could use this statement to get your current project document path:

myProjectPath = QgsProject.instance().readPath("./")

A basic implementation that you can add to startup.py:

from qgis.core import QgsProject

@qgsfunction(0, "Python")
def projectpath(values, feature, parent):
    return QgsProject.instance.fileName()
|improve this answer|||||
  • Bingo. That was going to be my answer too. – Nathan W Dec 16 '13 at 4:01
  • Updated your answer with a code example. – Nathan W Dec 16 '13 at 4:05
  • +1 Nice answer, but I don't think this will work for me as others may need to edit a project. Please see the edits to my question. – Fezter Dec 16 '13 at 4:16
  • 1
    There is no native way at the moment. – Nathan W Dec 16 '13 at 4:20
  • That's what I was afraid of. Thanks anyway. I'll look into implementing this solution across the company. – Fezter Dec 16 '13 at 4:27


[% @project_path %]

...in a QGIS print composer text label will print the file path in the same way as the dynamic text expression does in ArcMap (using QGIS 2.14).

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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