Class: QgsLayoutTableColumn

class qgis.core.QgsLayoutTableColumn

Bases: sip.wrapper

Stores properties of a column for a QgsLayoutTable.

Some properties of a QgsLayoutTableColumn are applicable only in certain contexts. For instance, the attribute and setAttribute methods only have an effect for QgsLayoutItemAttributeTables, and have no effect for QgsLayoutItemTextTables.

New in version 3.0.

QgsLayoutTableColumn(heading: str = ‘’) Constructor for QgsLayoutTableColumn.

Parameters:

heading – column heading

QgsLayoutTableColumn(QgsLayoutTableColumn)

Methods

attribute

Returns the attribute name or expression used for the column's values.

clone

Creates a duplicate column which is a deep copy of this column.

hAlignment

Returns the horizontal alignment for a column, which controls the alignment used for drawing column values within cells.

heading

Returns the heading for a column, which is the value displayed in the column's header cell.

readXml

Reads the column's properties from xml.

setAttribute

Sets the attribute name or expression used for the column's values.

setHAlignment

Sets the horizontal alignment for a column, which controls the alignment used for drawing column values within cells.

setHeading

Sets the heading for a column, which is the value displayed in the column's header cell.

setSortByRank

Sets the sort rank for the column.

setSortOrder

Sets the sort order for the column.

setVAlignment

Sets the vertical alignment for a column, which controls the alignment used for drawing column values within cells.

setWidth

Sets the width for a column in mm.

sortByRank

Returns the sort rank for the column.

sortOrder

Returns the sort order for the column.

vAlignment

Returns the vertical alignment for a column, which controls the alignment used for drawing column values within cells.

width

Returns the width for the column in mm, or 0 if column width is automatically calculated.

writeXml

Writes the column's properties to xml for storage.

attribute(self) str

Returns the attribute name or expression used for the column’s values. This property is only used when the column is part of a QgsLayoutItemAttributeTable.

Note

only applicable when used in a QgsLayoutItemAttributeTable

See also

setAttribute()

Return type:

str

clone(self) QgsLayoutTableColumn

Creates a duplicate column which is a deep copy of this column.

Return type:

QgsLayoutTableColumn

Returns:

a new QgsLayoutTableColumn with same properties as this column.

Deprecated since version QGIS: 3.14 use a copy instead

hAlignment(self) Qt.AlignmentFlag

Returns the horizontal alignment for a column, which controls the alignment used for drawing column values within cells.

See also

setHAlignment()

See also

vAlignment()

Return type:

Qt.AlignmentFlag

heading(self) str

Returns the heading for a column, which is the value displayed in the column’s header cell.

See also

setHeading()

Return type:

str

readXml(self, columnElem: QDomElement) bool

Reads the column’s properties from xml.

Parameters:

columnElem (QDomElement) – a QDomElement holding the column’s desired properties.

See also

writeXml()

Return type:

bool

setAttribute(self, attribute: str)

Sets the attribute name or expression used for the column’s values. This property is only used when the column is part of a QgsLayoutItemAttributeTable.

Note

only applicable when used in a QgsLayoutItemAttributeTable

See also

attribute()

Parameters:

attribute (str) –

setHAlignment(self, alignment: Qt.AlignmentFlag)

Sets the horizontal alignment for a column, which controls the alignment used for drawing column values within cells.

See also

hAlignment()

See also

setVAlignment()

Parameters:

alignment (Qt.AlignmentFlag) –

setHeading(self, heading: str)

Sets the heading for a column, which is the value displayed in the column’s header cell.

See also

heading()

Parameters:

heading (str) –

setSortByRank(self, rank: int)

Sets the sort rank for the column. If the sort rank is > 0 then the column will be sorted in the table. The sort rank specifies the priority given to the column when the table is sorted by multiple columns, with lower sort ranks having higher priority. This property is only used when the column is part of a QgsLayoutItemAttributeTable. If the sort rank is <= 0 then the column is not being sorted.

Note

only applicable when used in a QgsLayoutItemAttributeTable

See also

sortByRank()

See also

setSortOrder()

Deprecated since version QGIS: 3.14 the order is now hold in a dedicated model

Parameters:

rank (int) –

setSortOrder(self, order: Qt.SortOrder)

Sets the sort order for the column. This property is only used when the column is part of a QgsLayoutItemAttributeTable and when sortByRank() is > 0.

Note

only applicable when used in a QgsLayoutItemAttributeTable

See also

sortOrder()

See also

setSortByRank()

Parameters:

order (Qt.SortOrder) –

setVAlignment(self, alignment: Qt.AlignmentFlag)

Sets the vertical alignment for a column, which controls the alignment used for drawing column values within cells.

See also

vAlignment()

See also

setHAlignment()

Parameters:

alignment (Qt.AlignmentFlag) –

setWidth(self, width: float)

Sets the width for a column in mm. Set the width to 0 if the column width is to be automatically calculated.

See also

width()

Parameters:

width (float) –

sortByRank(self) int

Returns the sort rank for the column. If the sort rank is > 0 then the column will be sorted in the table. The sort rank specifies the priority given to the column when the table is sorted by multiple columns, with lower sort ranks having higher priority. This property is only used when the column is part of a QgsLayoutItemAttributeTable.

If sort rank is <= 0 then the column is not being sorted.

Note

only applicable when used in a QgsLayoutItemAttributeTable

See also

setSortByRank()

See also

sortOrder()

Deprecated since version QGIS: 3.14 the order is now hold in a dedicated model

Return type:

int

sortOrder(self) Qt.SortOrder

Returns the sort order for the column. This property is only used when the column is part of a QgsLayoutItemAttributeTable and when sortByRank is > 0.

Note

only applicable when used in a QgsLayoutItemAttributeTable

See also

setSortOrder()

See also

sortByRank()

Return type:

Qt.SortOrder

vAlignment(self) Qt.AlignmentFlag

Returns the vertical alignment for a column, which controls the alignment used for drawing column values within cells.

See also

setVAlignment()

See also

hAlignment()

Return type:

Qt.AlignmentFlag

width(self) float

Returns the width for the column in mm, or 0 if column width is automatically calculated.

See also

setWidth()

Return type:

float

writeXml(self, columnElem: QDomElement, doc: QDomDocument) bool

Writes the column’s properties to xml for storage.

Parameters:
  • columnElem (QDomElement) – an existing QDomElement in which to store the column’s properties.

  • doc (QDomDocument) – QDomDocument for the destination xml.

See also

readXml()

Return type:

bool