Table Of Contents

Previous topic

QTextFrameFormat

Next topic

QTextListFormat

QTextTableFormat

Inheritance diagram of QTextTableFormat

Synopsis

Functions

Detailed Description

The PySide.QtGui.QTextTableFormat class provides formatting information for tables in a PySide.QtGui.QTextDocument .

A table is a group of cells ordered into rows and columns. Each table contains at least one row and one column. Each cell contains a block. Tables in rich text documents are formatted using the properties defined in this class.

Tables are horizontally justified within their parent frame according to the table’s alignment. This can be read with the PySide.QtGui.QTextTableFormat.alignment() function and set with PySide.QtGui.QTextTableFormat.setAlignment() .

Cells within the table are separated by cell spacing. The number of pixels between cells is set with PySide.QtGui.QTextTableFormat.setCellSpacing() and read with PySide.QtGui.QTextTableFormat.cellSpacing() . The contents of each cell is surrounded by cell padding. The number of pixels between each cell edge and its contents is set with PySide.QtGui.QTextTableFormat.setCellPadding() and read with PySide.QtGui.QTextTableFormat.cellPadding() .

../../_images/qtexttableformat-cell.png

The table’s background color can be read with the PySide.QtGui.QTextFormat.background() function, and can be specified with PySide.QtGui.QTextFormat.setBackground() . The background color of each cell can be set independently, and will control the color of the cell within the padded area.

The table format also provides a way to constrain the widths of the columns in the table. Columns can be assigned a fixed width, a variable width, or a percentage of the available width (see PySide.QtGui.QTextLength ). The PySide.QtGui.QTextTableFormat.columns() function returns the number of columns with constraints, and the PySide.QtGui.QTextTableFormat.columnWidthConstraints() function returns the constraints defined for the table. These quantities can also be set by calling PySide.QtGui.QTextTableFormat.setColumnWidthConstraints() with a vector containing new constraints. If no constraints are required, PySide.QtGui.QTextTableFormat.clearColumnWidthConstraints() can be used to remove them.

class PySide.QtGui.QTextTableFormat
class PySide.QtGui.QTextTableFormat(fmt)
class PySide.QtGui.QTextTableFormat(QTextTableFormat)
Parameters:

Constructs a new table format object.

Creates a new table format with the same attributes as the given text format.

PySide.QtGui.QTextTableFormat.alignment()
Return type:PySide.QtCore.Qt.Alignment

Returns the table’s alignment.

PySide.QtGui.QTextTableFormat.cellPadding()
Return type:PySide.QtCore.qreal

Returns the table’s cell padding. This describes the distance between the border of a cell and its contents.

PySide.QtGui.QTextTableFormat.cellSpacing()
Return type:PySide.QtCore.qreal

Returns the table’s cell spacing. This describes the distance between adjacent cells.

PySide.QtGui.QTextTableFormat.clearColumnWidthConstraints()

Clears the column width constraints for the table.

PySide.QtGui.QTextTableFormat.columnWidthConstraints()
Return type:

Returns a list of constraints used by this table format to control the appearance of columns in a table.

PySide.QtGui.QTextTableFormat.columns()
Return type:PySide.QtCore.int

Returns the number of columns specified by the table format.

PySide.QtGui.QTextTableFormat.headerRowCount()
Return type:PySide.QtCore.int

Returns the number of rows in the table that define the header.

PySide.QtGui.QTextTableFormat.setAlignment(alignment)
Parameters:alignmentPySide.QtCore.Qt.Alignment
PySide.QtGui.QTextTableFormat.setCellPadding(padding)
Parameters:paddingPySide.QtCore.qreal

Sets the cell padding for the table. This determines the distance between the border of a cell and its contents.

PySide.QtGui.QTextTableFormat.setCellSpacing(spacing)
Parameters:spacingPySide.QtCore.qreal

Sets the cell spacing for the table. This determines the distance between adjacent cells.

PySide.QtGui.QTextTableFormat.setColumnWidthConstraints(constraints)
Parameters:constraints
PySide.QtGui.QTextTableFormat.setColumns(columns)
Parameters:columnsPySide.QtCore.int

Sets the number of columns required by the table format.

PySide.QtGui.QTextTableFormat.setHeaderRowCount(count)
Parameters:countPySide.QtCore.int

Declares the first count rows of the table as table header. The table header rows get repeated when a table is broken across a page boundary.