[Qgis-user] Expression to read field value from composer layout?
Patrick Dunford
enzedrailmaps at gmail.com
Tue Aug 3 13:16:31 PDT 2021
Good day
I am wishing to create a value in a field on a composer layout that
reads the value of another field on the layout and calculates a value to
be displayed.
For example, I have an existing field called Filename on the layout and
in a python script running in the main window console, I have this code
that reads the value of the Filename field as follows:
layoutTitle = "Landscape 16:9 Header Nav Copyright Filename 2021"
project = QgsProject.instance()
projectLayoutManager = project.layoutManager()
layout = projectLayoutManager.layoutByName(layoutTitle)
fileNameLabel = layout.itemById('Filename')
fileNameText = fileNameLabel.text()
Obviously I am hoping that doing this from a field within the layout
that reads another field on the same layout will be much simpler than
the above. How exactly would I achieve that?
Thanks in advance.
More information about the Qgis-user
mailing list