Class: QgsTableCell

Encapsulates the contents and formatting of a single table cell.

Added in version 3.12.

class qgis.core.QgsTableCell[source]

Bases: object

__init__(content: Any = None)

Constructor for QgsTableCell, with the specified content.

Parameters:

content (Any = None)

__init__(other: QgsTableCell)
Parameters:

other (QgsTableCell)

backgroundColor(self) QColor[source]

Returns the cell’s background color, or an invalid color if a default color should be used for the background.

Return type:

QColor

columnSpan(self) int[source]

Returns the column span for the cell.

See also

rowSpan()

See also

setSpan()

Added in version 3.40.

Return type:

int

content(self) Any[source]

Returns the cell’s content.

See also

setContent()

Return type:

Any

foregroundColor(self) QColor[source]

Returns the cell’s foreground color, or an invalid color if a default color should be used for the foreground.

Return type:

QColor

horizontalAlignment(self) Qt.Alignment[source]

Returns the horizontal alignment for text in the cell.

Added in version 3.16.

Return type:

Qt.Alignment

numericFormat(self) QgsNumericFormat | None[source]

Returns the numeric format used for numbers in the cell, or None if no format is set.

Return type:

Optional[QgsNumericFormat]

properties(self, context: QgsReadWriteContext) Dict[str, Any][source]

Returns the properties of the cell.

See also

setProperties()

Parameters:

context (QgsReadWriteContext)

Return type:

Dict[str, Any]

rowSpan(self) int[source]

Returns the row span for the cell.

See also

columnSpan()

See also

setSpan()

Added in version 3.40.

Return type:

int

setBackgroundColor(self, color: QColor | Qt.GlobalColor)[source]

Sets the cell’s background color.

Set an invalid color if a default color should be used for the background.

Parameters:

color (Union[QColor, Qt.GlobalColor])

setContent(self, content: Any)[source]

Sets the cell’s content.

See also

content()

Parameters:

content (Any)

setForegroundColor(self, color: QColor | Qt.GlobalColor)[source]

Sets the cell’s foreground color.

Set an invalid color if a default color should be used for the foreground.

Parameters:

color (Union[QColor, Qt.GlobalColor])

setHorizontalAlignment(self, alignment: Qt.Alignment | Qt.AlignmentFlag)[source]

Sets the horizontal alignment for text in the cell.

Added in version 3.16.

Parameters:

alignment (Union[Qt.Alignment, Qt.AlignmentFlag])

setNumericFormat(self, format: QgsNumericFormat | None)[source]

Sets the numeric format used for numbers in the cell, or None if no specific format is set.

Ownership of format is transferred to the cell.

See also

numericFormat()

Parameters:

format (Optional[QgsNumericFormat])

setProperties(self, properties: Dict[str, Any], context: QgsReadWriteContext)[source]

Sets the properties for the cell.

See also

properties()

Parameters:
setSpan(self, rowSpan: int, columnSpan: int)[source]

Sets the row and column span for the cell.

See also

rowSpan()

See also

columnSpan()

Added in version 3.40.

Parameters:
  • rowSpan (int)

  • columnSpan (int)

setTextFormat(self, format: QgsTextFormat)[source]

Sets the cell’s text format.

Note

The text format will only be used if hasTextFormat() returns True.

See also

textFormat()

Added in version 3.16.

Parameters:

format (QgsTextFormat)

setVerticalAlignment(self, alignment: Qt.Alignment | Qt.AlignmentFlag)[source]

Sets the vertical alignment for text in the cell.

Added in version 3.16.

Parameters:

alignment (Union[Qt.Alignment, Qt.AlignmentFlag])

textFormat(self) QgsTextFormat[source]

Returns the cell’s text format.

Note

The text format will only be used if hasTextFormat() returns True.

See also

setTextFormat()

Added in version 3.16.

Return type:

QgsTextFormat

verticalAlignment(self) Qt.Alignment[source]

Returns the vertical alignment for text in the cell.

Added in version 3.16.

Return type:

Qt.Alignment