[Qgis-user] Expression to read field value from composer layout?

Patrick Dunford enzedrailmaps at gmail.com
Tue Aug 3 19:38:01 PDT 2021


What's an atlas layer? I don't use the atlas functionality.


On 4/08/21 10:19 am, Nyall Dawson wrote:
> On Wed, 4 Aug 2021 at 06:17, Patrick Dunford <enzedrailmaps at gmail.com> wrote:
>> 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?
> Just to clarify -- by "field" do you mean "a field value from the
> atlas layer", or "a text label item"?
>
> Nyall


More information about the Qgis-user mailing list