[QGIS-Developer] QgsLayout LoadFromTemplate & substitutionMap
Nyall Dawson
nyall.dawson at gmail.com
Wed Feb 7 14:21:59 PST 2018
On 8 February 2018 at 08:10, Marc Ducobu <marc.ducobu at champs-libres.coop> wrote:
>
> With QgsComposition, it was possible to pass a "substitution map" to the
> method loadFromTemplate : the substitution map was a map/associative
> array such that when loading the template, strings like "[key]" were
> replaced by the value associated to the key ( see
> https://qgis.org/api/2.18/qgscomposition_8cpp_source.html#l01107 ).
>
> With QgsLayout, I have the impression that this feature has disappear.
> Do you know if it exists an alternative way to obtain an equivalent result ?
>
> Thanks a lot.
Yes - I removed that argument as it was unused in the code and looked
like a legacy leftover. My thoughts are that these substitutions would
be better performed now by placing expressions and through use of
expression variables directly inside the layout elements themselves -
e.g. instead of using the substitution to replace a label's text, put
an expression directly inside the label text and use the built in
expression functions or variables to evaluate to the desired text.
Alternatively, given that the argument was API only and not exposed to
users anywhere, it could also be done directly using built in python
replace methods prior to calling loadFromTemplate.
Nyall
More information about the QGIS-Developer
mailing list