1

Working with QGIS 2.14.10x64 in Windows 7 in the QGIS Python Console

I've managed to create a new print composer from a template, and update the layers in the map, and I'd now like to update the associate Composer Attribute Table. But when I use:

table = printcomposer['QgsComposition'].getComposerItemById('table')

I get a QgsComposerFrame object which doesn't inherit the the QgsComposerAttributeTable methods and can't seem to find any methods to access contents within the frame. Comparing table.uuid() with the uuid in the print composer shows that they are both the same.

1

You can use QgsComposerFrame.multiFrame():

table_frame = printcomposer['QgsComposition'].getComposerItemById('table')
table = table_frame.multiFrame()

Multiframe items like tables and HTML items can have their contents spread over multiple "frames". The getComposerItemById method is returning a frame for a table, but not the table itself. Calling the multiFrame() method returns the frame's parent QgsComposerMultiFrame object, which in this case will be a QgsComposerAttributeTableV2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.