5

Is there a way to access "other" composer element variables in QGIS?

I can "print" a variable in a text element by inputing for example: [% @project_title %], but is there a way to use the map_scale variable from a map element?

Anyting like: [% @map0(map_scale) %] ?

2
  • 2
    Not built in, no. You could possibly write a custom python function which would do this though.
    – ndawson
    May 23, 2016 at 2:46
  • That's cool! Could you give an example of such a function or point us to a tutorial? Jan 13, 2017 at 18:21

1 Answer 1

3

I do not have the answer for the general question, but in the specific case you pointed at, using "map scale" I do the following:

[%'Scale: 1:' || round(map_get(item_variables('Map 1'), 'map_scale')/100) || '00'%]

For this to work you have to give an ID to the desiderd map: Assign an ID to the map

(Done w/ Qgs 3.10)

Hope it hepls!

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.