[Qgis-user] Expression to read field value from composer layout?
Patrick Dunford
enzedrailmaps at gmail.com
Wed Aug 4 04:27:41 PDT 2021
I'm looking through the documentation and there is this example:
14.2.2.13. Layout Functions
<https://docs.qgis.org/3.10/en/docs/user_manual/working_with_vector/expression.html#id24>
This group contains functions to manipulate print layout items properties.
Function
Description
item_variables
Returns a map of variables from a layout item inside this print layout
*An example:*
*
Get the scale of the ‘Map 0’ in the current print layout:
map_get( item_variables('Map 0'), 'map_scale')
How do I find out how to get the text value of the layout item
"Filename" on the current print layout?
On 4/08/21 2:40 pm, Patrick Dunford wrote:
> It is just an ordinary text field on a composer layout I think. 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210804/b1c1b7f9/attachment.html>
More information about the Qgis-user
mailing list