Class: QgsTableCell

class qgis.core.QgsTableCell

Bases: sip.wrapper

Encapsulates the contents and formatting of a single table cell.

New in version 3.12.

QgsTableCell(content: Any = None) Constructor for QgsTableCell, with the specified content.

QgsTableCell(other: QgsTableCell) Copy constructor

Methods

backgroundColor

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

content

Returns the cell's content.

foregroundColor

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

horizontalAlignment

Returns the horizontal alignment for text in the cell.

numericFormat

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

properties

Returns the properties of the cell.

setBackgroundColor

Sets the cell's background color.

setContent

Sets the cell's content.

setForegroundColor

Sets the cell's foreground color.

setHorizontalAlignment

Sets the horizontal alignment for text in the cell.

setNumericFormat

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

setProperties

Sets the properties for the cell.

setTextFormat

Sets the cell's text format.

setVerticalAlignment

Sets the vertical alignment for text in the cell.

textFormat

Returns the cell's text format.

verticalAlignment

Returns the vertical alignment for text in the cell.

backgroundColor(self) QColor

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

Return type:

QColor

content(self) Any

Returns the cell’s content.

See also

setContent()

Return type:

Any

foregroundColor(self) QColor

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

Returns the horizontal alignment for text in the cell.

New in version 3.16.

Return type:

Qt.Alignment

numericFormat(self) QgsNumericFormat

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

Return type:

QgsNumericFormat

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

Returns the properties of the cell.

See also

setProperties()

Parameters:

context (QgsReadWriteContext) –

Return type:

Dict[str, Any]

setBackgroundColor(self, color: QColor | Qt.GlobalColor | QGradient)

Sets the cell’s background color.

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

Parameters:

color (Union[QColor) –

setContent(self, content: Any)

Sets the cell’s content.

See also

content()

Parameters:

content (Any) –

setForegroundColor(self, color: QColor | Qt.GlobalColor | QGradient)

Sets the cell’s foreground color.

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

Parameters:

color (Union[QColor) –

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

Sets the horizontal alignment for text in the cell.

New in version 3.16.

Parameters:

alignment (Union[Qt.Alignment) –

setNumericFormat(self, format: QgsNumericFormat)

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

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

Sets the properties for the cell.

See also

properties()

Parameters:
setTextFormat(self, format: QgsTextFormat)

Sets the cell’s text format.

Note

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

See also

textFormat()

New in version 3.16.

Parameters:

format (QgsTextFormat) –

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

Sets the vertical alignment for text in the cell.

New in version 3.16.

Parameters:

alignment (Union[Qt.Alignment) –

textFormat(self) QgsTextFormat

Returns the cell’s text format.

Note

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

See also

setTextFormat()

New in version 3.16.

Return type:

QgsTextFormat

verticalAlignment(self) Qt.Alignment

Returns the vertical alignment for text in the cell.

New in version 3.16.

Return type:

Qt.Alignment