Class: QgsTableCell

class qgis.core.QgsTableCell(content: Any = None)

Bases: sip.wrapper

Constructor for QgsTableCell, with the specified content.

QgsTableCell(other: QgsTableCell) Copy constructor

Encapsulates the contents and formatting of a single table cell.

New in version 3.12.

Parameters

content

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: Union[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: Union[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: Union[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: Union[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