Class: QgsLayoutItemManualTable

class qgis.core.QgsLayoutItemManualTable

Bases: QgsLayoutTable

A layout table subclass that displays manually entered (and formatted) content.

New in version 3.12.

QgsLayoutItemManualTable(layout: QgsLayout) Constructor for QgsLayoutItemManualTable, attached to the specified layout.

Ownership is transferred to the layout.

Methods

calculateMaxColumnWidths

Calculates the maximum width of text shown in columns.

calculateMaxRowHeights

rtype:

bool

childEvent

columnWidths

Returns the list of column widths (in millimeters) to use when rendering the table.

conditionalCellStyle

param row:

connectNotify

contentsContainsRow

Checks whether a table contents contains a given row

create

Returns a new QgsLayoutItemManualTable for the specified parent layout.

customEvent

disconnectNotify

displayName

rtype:

str

drawHorizontalGridLines

Draws the horizontal grid lines for the table.

headers

Returns a reference to the list of headers shown in the table

horizontalAlignmentForCell

param row:

icon

rtype:

QIcon

includeTableHeader

Returns True if the table includes a header row.

isSignalConnected

readObjectPropertiesFromElement

Sets object properties from a DOM element

readPropertiesFromElement

param itemElem:

recalculateTableSize

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

receivers

rowHeights

Returns the list of row heights (in millimeters) to use when rendering the table.

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

setColumnWidths

Sets the list of column widths (in millimeters) to use when rendering the table.

setHeaders

Replaces the headers in the table with a specified list of QgsLayoutTableColumns.

setIncludeTableHeader

Sets whether the table includes a header row.

setRowHeights

Sets the list of row heights (in millimeters) to use when rendering the table.

setTableContents

Sets the contents of the table.

tableContents

Returns the contents of the table.

textFormatForCell

param row:

textFormatForHeader

param column:

timerEvent

totalHeight

totalWidth

type

rtype:

int

verticalAlignmentForCell

param row:

writeObjectPropertiesToElement

Stores object properties within an XML DOM element.

writePropertiesToElement

param elem:

calculateMaxColumnWidths(self) bool

Calculates the maximum width of text shown in columns.

calculateMaxRowHeights(self) bool
Return type:

bool

childEvent(self, QChildEvent)
columnWidths(self) List[float]

Returns the list of column widths (in millimeters) to use when rendering the table.

A width of 0 indicates that the column width should be automatically calculated.

See also

rowHeights()

Return type:

List[float]

conditionalCellStyle(self, row: int, column: int) QgsConditionalStyle
Parameters:
  • row (int) –

  • column (int) –

Return type:

QgsConditionalStyle

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) QgsLayoutItemManualTable

Returns a new QgsLayoutItemManualTable for the specified parent layout.

Parameters:

layout (QgsLayout) –

Return type:

QgsLayoutItemManualTable

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()

headers(self) List[QgsLayoutTableColumn]

Returns a reference to the list of headers shown in the table

See also

setHeaders()

Return type:

List[QgsLayoutTableColumn]

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

  • column (int) –

Return type:

Qt.Alignment

icon(self) QIcon
Return type:

QIcon

includeTableHeader(self) bool

Returns True if the table includes a header row.

Return type:

bool

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

readPropertiesFromElement(self, itemElem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) bool
Parameters:
Return type:

bool

recalculateTableSize(self)

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

receivers(self, PYQT_SIGNAL) int
rowHeights(self) List[float]

Returns the list of row heights (in millimeters) to use when rendering the table.

A height of 0 indicates that the row height should be automatically calculated.

See also

setRowHeights()

See also

columnWidths()

Return type:

List[float]

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
setColumnWidths(self, widths: Iterable[float])

Sets the list of column widths (in millimeters) to use when rendering the table.

A width of 0 indicates that the column width should be automatically calculated.

See also

columnWidths()

Parameters:

widths (Iterable[float]) –

setHeaders(self, headers: Iterable[QgsLayoutTableColumn])

Replaces the headers in the table with a specified list of QgsLayoutTableColumns.

See also

headers()

Parameters:

headers (Iterable[QgsLayoutTableColumn]) –

setIncludeTableHeader(self, included: bool)

Sets whether the table includes a header row.

Parameters:

included (bool) –

setRowHeights(self, heights: Iterable[float])

Sets the list of row heights (in millimeters) to use when rendering the table.

A height of 0 indicates that the row height should be automatically calculated.

See also

rowHeights()

Parameters:

heights (Iterable[float]) –

setTableContents(self, contents: object)

Sets the contents of the table.

See also

tableContents()

Parameters:

contents (object) –

tableContents(self) object

Returns the contents of the table.

See also

contents()

Return type:

object

textFormatForCell(self, row: int, column: int) QgsTextFormat
Parameters:
  • row (int) –

  • column (int) –

Return type:

QgsTextFormat

textFormatForHeader(self, column: int) QgsTextFormat
Parameters:

column (int) –

Return type:

QgsTextFormat

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

int

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

  • column (int) –

Return type:

Qt.Alignment

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

writePropertiesToElement(self, elem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) bool
Parameters:
Return type:

bool