Using QGIS, the "General" project properties dialogue includes a "Project Title" area.

Is it possible to use the information inserted in this dialogue in an expression (specifically including within a label when using Composer)?

2 Answers 2


In QGIS 2.8, here's how I can get the project title into a text element in a map composer.

Add text element, hit "Insert an expression..."

Go to the Function Editor tab, create a new file, call it "project", and put this in it:

from qgis.core import *
from qgis.gui import *

@qgsfunction(args="auto", group='Custom')
def projtitle(value1, feature, parent):
    proj = QgsProject.instance()
    return proj.title()

Hit the green arrow button to run and that will check the syntax. Save it. Now you should have a new function you can put in the expression editor (in the Custom group), for example:

 [% projtitle( 0 )%]

in the text field for Map Composer text objects replaces it with the title from the settings.

I couldn't get it to work with no arguments, so the 0 is just a dummy.

Here's a screengrab of the various components showing it in action.

project title insertion


This has been implemented in QGIS 2.14's composer within the expression builder that is called by the 'Insert an expression' button when a text box is active.

They are called 'variables' now and you can call a great variety of them with the syntax "[% @qgis_version %]" right in the text box. The expression builder will also take care of those brackets and percent signs for you, if you can enter a valid expression. Variables in QGIS print composer.

Please see Nyall Dawson's great blog posts about variables in QGIS:

Your Answer

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

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