Subgroup: Layout

Class: QgsLayoutItemAttributeTable

class qgis.core.QgsLayoutItemAttributeTable

Bases: qgis._core.QgsLayoutTable

A layout table subclass that displays attributes from a vector layer.

New in version 3.0: Methods

addFrame Adds a frame to the multiframe.
backgroundColor Returns the color used for the background of the table.
beginCommand Starts new undo command for this item.
blockSignals
calculateMaxColumnWidths
calculateMaxRowHeights
cancelCommand Cancels the current item command and discards it.
cellMargin Returns the margin distance between cell borders and their contents in mm.
cellStyle Returns the cell style for a cell group.
childEvent
children
columns Returns a reference to the list of QgsLayoutTableColumns shown in the table
connectNotify
contentFont Returns the font used to draw text in table body cells.
contentFontColor Returns the color used to draw text in table body cells.
contents Returns the current contents of the table.
contentsContainsRow
create Returns a new QgsLayoutItemAttributeTable for the specified parent layout.
createCommand
createExpressionContext
createNewFrame Creates a new frame and adds it to the multi frame and layout.
customEvent
customProperties Return list of keys stored in custom properties for the object.
customProperty Read a custom property from the object.
dataDefinedProperties Returns a reference to the object’s property collection, used for data defined overrides.
deleteFrames Removes and deletes all child frames.
deleteLater
disconnect
disconnectNotify
displayName
displayOnlyVisibleFeatures Returns true if the table is set to show only features visible on a corresponding map item.
drawHorizontalGridLines
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
emptyTableBehavior Returns the behavior mode for empty tables.
emptyTableMessage Returns the message for empty tables with no content rows.
endCommand Completes the current item command and push it onto the layout’s undo stack.
event
eventFilter
featureFilter Returns the current expression used to filter features for the table.
filterFeatures Returns true if a feature filter is active on the attribute table.
filterToAtlasFeature Returns true if the table is set to only show features which intersect the current atlas feature.
finalizeRestoreFromXml Called after all pending items have been restored from XML.
findChild findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject
findChildren findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]
findNearbyPageBreak Finds the optimal position to break a frame at.
fixedFrameSize
frame Returns the child frame at a specified index from the multiframe.
frameCount Returns the number of frames associated with this multiframe.
frameIndex Returns the index of a frame within the multiframe.
frames Returns a list of all child frames for this multiframe.
getTableContents Fetches the contents used for the cells in the table.
gridColor Returns the color used for grid lines in the table.
gridStrokeWidth Returns the width of grid lines in the table in mm.
headerFont Returns the font used to draw header text in the table.
headerFontColor Returns the color used to draw header text in the table.
headerHAlignment Returns the horizontal alignment for table headers.
headerMode Returns the display mode for headers in the table.
horizontalGrid Returns whether the grid’s horizontal lines are drawn in the table.
icon
inherits
installEventFilter
isSignalConnected
isWidgetType
isWindowType
killTimer
layout Returns the layout the object is attached to.
map Returns the layout map whose extents are controlling the features shown in the table.
maximumNumberOfFeatures Returns the maximum number of features to be shown by the table.
metaObject
minFrameSize
moveToThread
objectName
parent
property
propertyDefinitions Returns the layout object property definitions.
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
readObjectPropertiesFromElement
readPropertiesFromElement
readXml Sets the item state from a DOM element.
recalculateFrameRects Forces a recalculation of all the associated frame’s scene rectangles.
recalculateFrameSizes
recalculateTableSize
receivers
refresh
refreshAttributes Refreshes the contents shown in the table by querying for new data.
refreshDataDefinedProperty Refreshes a data defined property for the multi frame by reevaluating the property’s value and redrawing the item with this new value.
relationId Returns the relation id which the table displays child features from.
removeCustomProperty Remove a custom property from the object.
removeEventFilter
removeFrame Removes a frame by index from the multiframe.
render
resetColumns Resets the attribute table’s columns to match the vector layer’s fields.
resizeMode Returns the resize mode for the multiframe.
rowRange
rowsVisible
sender
senderSignalIndex
setBackgroundColor Sets the color used for background of table.
setCellMargin Sets the margin distance in mm between cell borders and their contents.
setCellStyle Sets the cell style for a cell group.
setColumns Replaces the columns in the table with a specified list of QgsLayoutTableColumns.
setContentFont Sets the font used to draw text in table body cells.
setContentFontColor Sets the color used to draw text in table body cells.
setCustomProperty Set a custom property for the object.
setDataDefinedProperties Sets the objects’s property collection, used for data defined overrides.
setDisplayOnlyVisibleFeatures Sets the attribute table to only show features which are visible in a map item.
setDisplayedFields Sets the attributes to display in the table.
setEmptyTableBehavior Sets the behavior mode for empty tables with no content rows.
setEmptyTableMessage Sets the message for empty tables with no content rows.
setFeatureFilter Sets the expression used for filtering features in the table.
setFilterFeatures Sets whether the feature filter is active for the attribute table.
setFilterToAtlasFeature Sets attribute table to only show features which intersect the current atlas feature.
setGridColor Sets the color used for grid lines in the table.
setGridStrokeWidth Sets the width in mm for grid lines in the table.
setHeaderFont Sets the font used to draw header text in the table.
setHeaderFontColor Sets the color used to draw header text in the table.
setHeaderHAlignment Sets the horizontal alignment for table headers.
setHeaderMode Sets the display mode for headers in the table.
setHorizontalGrid Sets whether the grid’s horizontal lines should be drawn in the table
setMap Sets a layout map to use to limit the extent of features shown in the attribute table.
setMaximumNumberOfFeatures Sets the maximum number of features shown by the table.
setObjectName
setParent
setProperty
setRelationId Sets the relation id from which to display child features
setResizeMode Sets the resize mode for the multiframe, and recalculates frame sizes to match.
setShowEmptyRows Sets whether empty rows should be drawn.
setShowGrid Sets whether grid lines should be drawn in the table
setSource Sets the source for attributes to show in table body.
setUniqueRowsOnly Sets attribute table to only show unique rows.
setVectorLayer Sets the vector layer from which to display feature attributes.
setVerticalGrid Sets whether the grid’s vertical lines should be drawn in the table
setWrapBehavior Sets the wrap behavior for the table, which controls how text within cells is automatically wrapped.
setWrapString Sets a string to wrap the contents of the table cells by.
showEmptyRows Returns whether empty rows are drawn in the table.
showGrid Returns whether grid lines are drawn in the table
signalsBlocked
source Returns the source for attributes shown in the table body.
sourceLayer Returns the source layer for the table, considering the table source mode.
startTimer
thread
timerEvent
totalHeight
totalSize
totalWidth
tr
type
uniqueRowsOnly Returns true if the table is set to show only unique rows.
update Forces a redraw of all child frames.
uuid Returns the multiframe identification string.
vectorLayer Returns the vector layer the attribute table is currently using.
verticalGrid Returns whether the grid’s vertical lines are drawn in the table.
wrapBehavior Returns the wrap behavior for the table, which controls how text within cells is automatically wrapped.
wrapString Returns the string used to wrap the contents of the table cells by.
writeObjectPropertiesToElement
writePropertiesToElement
writeXml Stores the multiframe state in a DOM element.

Attributes

AllFrames
AllProperties
AtlasFeature
BackgroundColor
BlendMode
EvaluatedValue
EvenColumns
EvenRows
ExcludeFromExports
ExtendToNextPage
FirstColumn
FirstFrame
FirstRow
FollowColumn
FrameColor
HeaderCenter
HeaderLeft
HeaderRight
HeaderRow
HeadersOnly
HideTable
ItemHeight
ItemRotation
ItemWidth
LastColumn
LastRow
LayerAttributes
LegendColumnCount
LegendTitle
MapAtlasMargin
MapLayers
MapRotation
MapScale
MapStylePreset
MapXMax
MapXMin
MapYMax
MapYMin
NoHeaders
NoProperty
NumPages
OddColumns
OddRows
Opacity
OriginalValue
PageNumber
PaperHeight
PaperOrientation
PaperWidth
PictureSource
PictureSvgBackgroundColor
PictureSvgStrokeColor
PictureSvgStrokeWidth
PositionX
PositionY
PresetPaperSize
RelationChildren
RepeatOnEveryPage
RepeatUntilFinished
ScalebarFillColor
ScalebarFillColor2
ScalebarLineColor
ScalebarLineWidth
ShowMessage
SourceUrl
TestProperty
Transparency
TruncateText
UndoHtmlBreakDistance
UndoHtmlSource
UndoHtmlStylesheet
UndoNone
UndoTableBackgroundColor
UndoTableCellStyle
UndoTableContentFontColor
UndoTableGridColor
UndoTableGridStrokeWidth
UndoTableHeaderFontColor
UndoTableMargin
UndoTableMaximumFeatures
UseExistingFrames
WrapText
changed Emitted when the properties of a multi frame have changed, and the GUI item widget must be updated.
contentsChanged Emitted when the contents of the multi frame have changed and the frames must be redrawn.
destroyed destroyed(self, QObject = None) [signal]
objectNameChanged objectNameChanged(self, str) [signal]
staticMetaObject
AtlasFeature = 1
class ContentSource

Bases: int

LayerAttributes = 0
RelationChildren = 2
calculateMaxColumnWidths()
calculateMaxRowHeights()
childEvent()
connectNotify()
contentsContainsRow()
create(layout: QgsLayout) → QgsLayoutItemAttributeTable

Returns a new QgsLayoutItemAttributeTable for the specified parent layout.

createExpressionContext(self) → QgsExpressionContext
customEvent()
disconnectNotify()
displayName(self) → str
displayOnlyVisibleFeatures(self) → bool

Returns true if the table is set to show only features visible on a corresponding map item.

See also

map()

drawHorizontalGridLines()
featureFilter(self) → str

Returns the current expression used to filter features for the table. The filter is only active if filterFeatures() is true.

See also

filterFeatures()

filterFeatures(self) → bool

Returns true if a feature filter is active on the attribute table.

See also

featureFilter()

filterToAtlasFeature(self) → bool

Returns true if the table is set to only show features which intersect the current atlas feature.

icon(self) → QIcon
isSignalConnected()
map(self) → QgsLayoutItemMap

Returns the layout map whose extents are controlling the features shown in the table. The extents of the map are only used if displayOnlyVisibleFeatures() is true.

See also

setMap()

maximumNumberOfFeatures(self) → int

Returns the maximum number of features to be shown by the table.

readObjectPropertiesFromElement()
readPropertiesFromElement(self, itemElem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) → bool
recalculateTableSize()
receivers()
relationId(self) → str

Returns the relation id which the table displays child features from.

See also

setRelationId()

See also

source()

Note

Only used if table source() is set to RelationChildren.

resetColumns(self)

Resets the attribute table’s columns to match the vector layer’s fields.

See also

setVectorLayer()

rowRange()
rowsVisible()
sender()
senderSignalIndex()
setDisplayOnlyVisibleFeatures(self, visibleOnly: bool)

Sets the attribute table to only show features which are visible in a map item. Changing this setting forces the table to refetch features from its vector layer, and may result in the table changing size to accommodate the new displayed feature attributes.

See also

setMap()

setDisplayedFields(self, fields: Iterable[str], refresh: bool = True)

Sets the attributes to display in the table.

Parameters:fields – list of fields names from the vector layer to show.

Set to an empty list to show all feature attributes. :param refresh: set to true to force the table to refetch features from its vector layer and immediately update the display of the table. This may result in the table changing size to accommodate the new displayed feature attributes.

setFeatureFilter(self, expression: str)

Sets the expression used for filtering features in the table. The filter is only active if filterFeatures() is set to true. Changing this setting forces the table to refetch features from its vector layer, and may result in the table changing size to accommodate the new displayed feature attributes.

See also

featureFilter()

setFilterFeatures(self, filter: bool)

Sets whether the feature filter is active for the attribute table. Changing this setting forces the table to refetch features from its vector layer, and may result in the table changing size to accommodate the new displayed feature attributes.

See also

filterFeatures()

setFilterToAtlasFeature(self, filterToAtlas: bool)

Sets attribute table to only show features which intersect the current atlas feature.

setMap(self, map: QgsLayoutItemMap)

Sets a layout map to use to limit the extent of features shown in the attribute table. This setting only has an effect if setDisplayOnlyVisibleFeatures is set to true. Changing the map forces the table to refetch features from its vector layer, and may result in the table changing size to accommodate the new displayed feature attributes.

See also

map()

setMaximumNumberOfFeatures(self, features: int)

Sets the maximum number of features shown by the table. Changing this setting may result in the attribute table changing its size to accommodate the new number of rows, and requires the table to refetch features from its vector layer.

setRelationId(self, id: str)

Sets the relation id from which to display child features

See also

relationId()

See also

setSource()

Note

Only used if table source() is set to RelationChildren.

setSource(self, source: QgsLayoutItemAttributeTable.ContentSource)

Sets the source for attributes to show in table body.

See also

source()

setUniqueRowsOnly(self, uniqueOnly: bool)

Sets attribute table to only show unique rows.

Set uniqueOnly to true to show only unique rows. Duplicate rows will be stripped from the table.

See also

uniqueRowsOnly()

setVectorLayer(self, layer: QgsVectorLayer)

Sets the vector layer from which to display feature attributes.

This is only considered if the table source() is LayerAttributes.

See also

vectorLayer()

setWrapString(self, wrapString: str)

Sets a string to wrap the contents of the table cells by. Occurrences of this string will be replaced by a line break.

Parameters:wrapString – string to replace with line break

See also

wrapString()

source(self) → QgsLayoutItemAttributeTable.ContentSource

Returns the source for attributes shown in the table body.

See also

setSource()

sourceLayer(self) → QgsVectorLayer

Returns the source layer for the table, considering the table source mode. For example, if the table is set to atlas feature mode, then the source layer will be the atlas coverage layer. If the table is set to layer attributes mode, then the source layer will be the user specified vector layer.

timerEvent()
totalHeight()
totalWidth()
type(self) → int
uniqueRowsOnly(self) → bool

Returns true if the table is set to show only unique rows.

vectorLayer(self) → QgsVectorLayer

Returns the vector layer the attribute table is currently using.

This is only considered if the table source() is LayerAttributes.

See also

setVectorLayer()

See also

sourceLayer()

wrapString(self) → str

Returns the string used to wrap the contents of the table cells by. Occurrences of this string will be replaced by a line break.

See also

setWrapString()

writeObjectPropertiesToElement()
writePropertiesToElement(self, elem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) → bool