Class: QgsLayoutItemTextTable

class qgis.core.QgsLayoutItemTextTable(layout: QgsLayout)

Bases: QgsLayoutTable

Constructor for QgsLayoutItemTextTable, for the specified layout.

Ownership is transferred to the layout.

A text table item that reads text from string lists

Methods

addRow

Adds a row to the table

calculateMaxColumnWidths

Calculates the maximum width of text shown in columns.

calculateMaxRowHeights

Calculates the maximum height of text shown in rows.

childEvent

connectNotify

contentsContainsRow

Checks whether a table contents contains a given row

create

Returns a new QgsLayoutItemTextTable for the specified parent layout.

customEvent

disconnectNotify

displayName

rtype

str

drawHorizontalGridLines

Draws the horizontal grid lines for the table.

getTableContents

param contents

horizontalAlignmentForCell

Returns the horizontal alignment to use for the cell at the specified row and column.

isSignalConnected

readObjectPropertiesFromElement

Sets object properties from a DOM element

recalculateTableSize

Recalculates and updates the size of the table and all table frames.

receivers

rowRange

Calculates a range of rows which should be visible in a given frame.

rowsVisible

Calculates how many content rows would be visible within a frame of the specified height.

sender

senderSignalIndex

setContents

Sets the contents of the text table.

textFormatForCell

Returns the text format to use for the cell at the specified row and column.

textFormatForHeader

Returns the text format to use for the header cell at the specified column.

timerEvent

totalHeight

totalWidth

type

rtype

int

verticalAlignmentForCell

Returns the vertical alignment to use for the cell at the specified row and column.

writeObjectPropertiesToElement

Stores object properties within an XML DOM element.

addRow(self, row: Iterable[str])

Adds a row to the table

Parameters

row (Iterable[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

calculateMaxColumnWidths(self)bool

Calculates the maximum width of text shown in columns.

calculateMaxRowHeights(self)bool

Calculates the maximum height of text shown in rows.

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
contentsContainsRow(self, contents: object, row: Iterable[Any])bool

Checks whether a table contents contains a given row

Parameters
  • contents – table contents to check

  • row – row to check for

Returns

True if contents contains rows

create(layout: QgsLayout)QgsLayoutItemTextTable

Returns a new QgsLayoutItemTextTable for the specified parent layout.

Parameters

layout (QgsLayout) –

Return type

QgsLayoutItemTextTable

customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
displayName(self)str
Return type

str

drawHorizontalGridLines(self, context: QgsLayoutItemRenderContext, firstRow: int, lastRow: int, drawHeaderLines: bool)

Draws the horizontal grid lines for the table.

Parameters
  • context – destination render context

  • firstRow – index corresponding to first row shown in frame

  • lastRow – index corresponding to last row shown in frame. If greater than the number of content rows in the table, then the default row height will be used for the remaining rows.

  • drawHeaderLines – set to True to include for the table header

See also

drawVerticalGridLines()

getTableContents(self, contents: object)bool
Parameters

contents (object) –

Return type

bool

horizontalAlignmentForCell(self, row: int, column: int)Qt.Alignment

Returns the horizontal alignment to use for the cell at the specified row and column.

New in version 3.16.

isSignalConnected(self, QMetaMethod)bool
readObjectPropertiesFromElement(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext)bool

Sets object properties from a DOM element

Parameters
  • parentElement – is the parent DOM element for the object

  • document – DOM document

  • context – read write context

Returns

True if read was successful

recalculateTableSize(self)

Recalculates and updates the size of the table and all table frames.

receivers(self, PYQT_SIGNAL)int
rowRange(self, context: QgsRenderContext, frameIndex: int)Tuple[int, int]

Calculates a range of rows which should be visible in a given frame.

Parameters
  • context – render context

  • frameIndex – index number for frame

Returns

row range

rowsVisible(self, context: QgsRenderContext, frameHeight: float, firstRow: int, includeHeader: bool, includeEmptyRows: bool)int

Calculates how many content rows would be visible within a frame of the specified height.

Parameters
  • context – render context

  • frameHeight – height of frame

  • firstRow – index of first row visible in frame (where 0 = first row in table)

  • includeHeader – set to True if frame would include a header row

  • includeEmptyRows – set to True to also include rows which would be empty in the returned count. For instance, if the frame would include all table content rows and have space left for extra rows then setting this parameter to True would also include a count of these extra blank rows.

Returns

number of visible content rows (excluding header row)

rowsVisible(self, context: QgsRenderContext, frameIndex: int, firstRow: int, includeEmptyRows: bool) -> int Calculates how many content rows are visible within a given frame.

Parameters
  • context – render context

  • frameIndex – index number for frame

  • firstRow – index of first row visible in frame (where 0 = first row in table)

  • includeEmptyRows – set to True to also include rows which would be empty in the returned count. For instance, if the frame would include all table content rows and have space left for extra rows then setting this parameter to True would also include a count of these extra blank rows.

Returns

number of visible content rows (excludes header rows)

sender(self)QObject
senderSignalIndex(self)int
setContents(self, contents: Iterable[Iterable[str]])

Sets the contents of the text table.

Parameters

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

See also

addRow()

textFormatForCell(self, row: int, column: int)QgsTextFormat

Returns the text format to use for the cell at the specified row and column.

New in version 3.16.

textFormatForHeader(self, column: int)QgsTextFormat

Returns the text format to use for the header cell at the specified column.

New in version 3.16.

timerEvent(self, QTimerEvent)
totalHeight(self)float
totalWidth(self)float
type(self)int
Return type

int

verticalAlignmentForCell(self, row: int, column: int)Qt.Alignment

Returns the vertical alignment to use for the cell at the specified row and column.

New in version 3.16.

writeObjectPropertiesToElement(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext)bool

Stores object properties within an XML DOM element.

Parameters
  • parentElement – is the parent DOM element to store the object’s properties in

  • document – DOM document

  • context – read write context

Returns

True if write was successful