PySide6.QtGui.QTextTableFormat¶
- class QTextTableFormat¶
- The - QTextTableFormatclass provides formatting information for tables in a- QTextDocument. More…- Synopsis¶- Methods¶- def - __init__()
- def - alignment()
- def - borderCollapse()
- def - cellPadding()
- def - cellSpacing()
- def - columns()
- def - headerRowCount()
- def - setAlignment()
- def - setCellPadding()
- def - setCellSpacing()
- def - setColumns()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- 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 - alignment()function and set with- setAlignment().- Cells within the table are separated by cell spacing. The number of pixels between cells is set with - setCellSpacing()and read with- 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- setCellPadding()and read with- cellPadding().  - The table’s background color can be read with the - background()function, and can be specified with- 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 - QTextLength). The- columns()function returns the number of columns with constraints, and the- columnWidthConstraints()function returns the constraints defined for the table. These quantities can also be set by calling- setColumnWidthConstraints()with a list containing new constraints. If no constraints are required,- clearColumnWidthConstraints()can be used to remove them.- See also - __init__()¶
 - Constructs a new table format object. - __init__(fmt)
- Parameters:
- fmt – - QTextFormat
 
 - alignment()¶
- Return type:
- Combination of - AlignmentFlag
 
 - Returns the table’s alignment. - See also - borderCollapse()¶
- Return type:
- bool 
 
 - Returns true if borderCollapse is enabled. - See also - cellPadding()¶
- Return type:
- float 
 
 - Returns the table’s cell padding. This describes the distance between the border of a cell and its contents. - See also - cellSpacing()¶
- Return type:
- float 
 
 - Returns the table’s cell spacing. This describes the distance between adjacent cells. - See also - clearColumnWidthConstraints()¶
 - Clears the column width constraints for the table. - columnWidthConstraints()¶
- Return type:
- .list of QTextLength 
 
 - Returns a list of constraints used by this table format to control the appearance of columns in a table. - See also - columns()¶
- Return type:
- int 
 
 - Returns the number of columns specified by the table format. - headerRowCount()¶
- Return type:
- int 
 
 - Returns the number of rows in the table that define the header. - See also - setAlignment(alignment)¶
- Parameters:
- alignment – Combination of - AlignmentFlag
 
 - Sets the table’s - alignment.- See also - setBorderCollapse(borderCollapse)¶
- Parameters:
- borderCollapse – bool 
 
 - Enabling - borderCollapsewill have the following implications:- The borders and grid of the table will be rendered following the CSS table - border-collapse:- collapserules
- Setting the - borderproperty to a minimum value of- 1will render a one pixel solid inner table grid using the- borderBrushproperty and an outer border as specified
- The various border style properties of - QTextTableCellFormatcan be used to customize the grid and have precedence over the border and grid of the table
- The - cellSpacingproperty will be ignored
- For print pagination: - Columns continued on a page will not have their top cell border rendered 
- Repeated header rows will always have their bottom cell border rendered 
 
 - With - borderCollapsedisabled, cell borders can still be styled using- QTextTableCellFormatbut styling will be applied only within the cell’s frame, which is probably not very useful in practice.- setCellPadding(padding)¶
- Parameters:
- padding – float 
 
 - Sets the cell - paddingfor the table. This determines the distance between the border of a cell and its contents.- See also - setCellSpacing(spacing)¶
- Parameters:
- spacing – float 
 
 - Sets the cell - spacingfor the table. This determines the distance between adjacent cells.- This property will be ignored if - borderCollapseis enabled.- See also - setColumnWidthConstraints(constraints)¶
- Parameters:
- constraints – .list of QTextLength 
 
 - Sets the column width - constraintsfor the table.- setColumns(columns)¶
- Parameters:
- columns – int 
 
 - setHeaderRowCount(count)¶
- Parameters:
- count – int 
 
 - Declares the first - countrows of the table as table header. The table header rows get repeated when a table is broken across a page boundary.- See also