QgsLayoutTableColumn class

Stores properties of a column for a QgsLayoutTable.

Some properties of aQgsLayoutTableColumn 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.

Constructors, destructors, conversion operators

QgsLayoutTableColumn(const QString& heading = QString())
Constructor for QgsLayoutTableColumn.

Public functions

auto attribute() const -> QString
Returns the attribute name or expression used for the column's values.
auto clone() -> QgsLayoutTableColumn*
Creates a duplicate column which is a deep copy of this column.
auto hAlignment() const -> Qt::AlignmentFlag
Returns the horizontal alignment for a column, which controls the alignment used for drawing column values within cells.
auto heading() const -> QString
Returns the heading for a column, which is the value displayed in the column's header cell.
auto readXml(const QDomElement& columnElem) -> bool
Reads the column's properties from xml.
void setAttribute(const QString& attribute)
Sets the attribute name or expression used for the column's values.
void setHAlignment(Qt::AlignmentFlag alignment)
Sets the horizontal alignment for a column, which controls the alignment used for drawing column values within cells.
void setHeading(const QString& heading)
Sets the heading for a column, which is the value displayed in the column's header cell.
void setSortByRank(int rank)
Sets the sort rank for the column.
void setSortOrder(Qt::SortOrder order)
Sets the sort order for the column.
void setVAlignment(Qt::AlignmentFlag alignment)
Sets the vertical alignment for a column, which controls the alignment used for drawing column values within cells.
void setWidth(const double width)
Sets the width for a column in mm.
auto sortByRank() const -> int
Returns the sort rank for the column.
auto sortOrder() const -> Qt::SortOrder
Returns the sort order for the column.
auto vAlignment() const -> Qt::AlignmentFlag
Returns the vertical alignment for a column, which controls the alignment used for drawing column values within cells.
auto width() const -> double
Returns the width for the column in mm, or 0 if column width is automatically calculated.
auto writeXml(QDomElement& columnElem, QDomDocument& doc) const -> bool
Writes the column's properties to xml for storage.

Function documentation

QgsLayoutTableColumn::QgsLayoutTableColumn(const QString& heading = QString())

Constructor for QgsLayoutTableColumn.

Parameters
heading column heading

QString QgsLayoutTableColumn::attribute() const

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.

QgsLayoutTableColumn* QgsLayoutTableColumn::clone()

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

Returns a new QgsLayoutTableColumn with same properties as this column.

Qt::AlignmentFlag QgsLayoutTableColumn::hAlignment() const

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

QString QgsLayoutTableColumn::heading() const

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

bool QgsLayoutTableColumn::readXml(const QDomElement& columnElem)

Reads the column's properties from xml.

Parameters
columnElem a QDomElement holding the column's desired properties.

void QgsLayoutTableColumn::setAttribute(const QString& attribute)

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.

void QgsLayoutTableColumn::setHAlignment(Qt::AlignmentFlag alignment)

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

void QgsLayoutTableColumn::setHeading(const QString& heading)

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

void QgsLayoutTableColumn::setSortByRank(int rank)

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 QgsComposerAttributeTable. If the sort rank is <= 0 then the column is not being sorted.

void QgsLayoutTableColumn::setSortOrder(Qt::SortOrder order)

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.

void QgsLayoutTableColumn::setVAlignment(Qt::AlignmentFlag alignment)

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

void QgsLayoutTableColumn::setWidth(const double width)

Sets the width for a column in mm.

Set the width to 0 if the column width is to be automatically calculated.

int QgsLayoutTableColumn::sortByRank() const

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.

Qt::SortOrder QgsLayoutTableColumn::sortOrder() const

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.

Qt::AlignmentFlag QgsLayoutTableColumn::vAlignment() const

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

double QgsLayoutTableColumn::width() const

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

bool QgsLayoutTableColumn::writeXml(QDomElement& columnElem, QDomDocument& doc) const

Writes the column's properties to xml for storage.

Parameters
columnElem an existing QDomElement in which to store the column's properties.
doc QDomDocument for the destination xml.