Class: QgsLayoutItemTextTable

A text table item that reads text from string lists.

Class Hierarchy

Inheritance diagram of qgis.core.QgsLayoutItemTextTable

Base classes

QgsLayoutTable

Displays a table in the print layout, and allows the table to span over multiple frames.

QgsLayoutMultiFrame

Abstract base class for layout items with the ability to distribute the content to several frames (QgsLayoutFrame items).

QgsLayoutObject

A base class for objects which belong to a layout.

QObject

QgsExpressionContextGenerator

Abstract interface for generating an expression context.

QgsLayoutUndoObjectInterface

Interface for layout objects which support undo/redo commands.

Methods

addRow

Adds a row to the table

setContents

Sets the contents of the text table.

Static Methods

create

Returns a new QgsLayoutItemTextTable for the specified parent layout.

class qgis.core.QgsLayoutItemTextTable[source]

Bases: QgsLayoutTable

__init__(layout: QgsLayout | None)

Constructor for QgsLayoutItemTextTable, for the specified layout.

Ownership is transferred to the layout.

Parameters:

layout (Optional[QgsLayout])

addRow(self, row: Iterable[str | None])[source]

Adds a row to the table

Parameters:

row (Iterable[Optional[str]]) – list of strings to use for each cell’s value in the newly added row

Note

If row is shorter than the number of columns in the table than blank cells will be inserted at the end of the row. If row contains more strings then the number of columns in the table then these extra strings will be ignored.

Note

if adding many rows, setContents() is much faster

static create(layout: QgsLayout | None) QgsLayoutItemTextTable | None[source]

Returns a new QgsLayoutItemTextTable for the specified parent layout.

Parameters:

layout (Optional[QgsLayout])

Return type:

Optional[QgsLayoutItemTextTable]

setContents(self, contents: Iterable[Iterable[str | None]])[source]

Sets the contents of the text table.

Parameters:

contents (Iterable[Iterable[Optional[str]]]) – list of table rows

See also

addRow()