QTextTableFormat 类

The QTextTableFormat 类为表格提供格式化信息在 QTextDocument . 更多...

头: #include <QTextTableFormat>
qmake: QT += gui
继承: QTextFrameFormat

注意: 此类的所有函数 可重入 .

公共函数

QTextTableFormat ()
Qt::Alignment alignment () const
qreal cellPadding () const
qreal cellSpacing () const
void clearColumnWidthConstraints ()
QVector<QTextLength> columnWidthConstraints () const
int columns () const
int headerRowCount () const
bool isValid () const
void setAlignment (Qt::Alignment alignment )
void setCellPadding (qreal padding )
void setCellSpacing (qreal spacing )
void setColumnWidthConstraints (const QVector<QTextLength> & constraints )
void setHeaderRowCount (int count )

详细描述

The QTextTableFormat 类为表格提供格式化信息在 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 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 )。 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 vector containing new constraints. If no constraints are required, clearColumnWidthConstraints () can be used to remove them.

另请参阅 QTextTable , QTextTableCell ,和 QTextLength .

成员函数文档编制

QTextTableFormat:: QTextTableFormat ()

构造新的表格格式对象。

Qt::Alignment QTextTableFormat:: alignment () const

返回表格的对齐方式。

另请参阅 setAlignment ().

qreal QTextTableFormat:: cellPadding () const

返回表格的单元格铺垫。这描述单元格边框与其内容之间的距离。

另请参阅 setCellPadding ().

qreal QTextTableFormat:: cellSpacing () const

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

另请参阅 setCellSpacing ().

void QTextTableFormat:: clearColumnWidthConstraints ()

Clears the column width constraints for the table.

另请参阅 columnWidthConstraints () 和 setColumnWidthConstraints ().

QVector < QTextLength > QTextTableFormat:: columnWidthConstraints () const

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

另请参阅 setColumnWidthConstraints ().

int QTextTableFormat:: columns () const

Returns the number of columns specified by the table format.

int QTextTableFormat:: headerRowCount () const

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

该函数在 Qt 4.2 引入。

另请参阅 setHeaderRowCount ().

bool QTextTableFormat:: isValid () const

返回 true if this table format is valid; otherwise returns false .

void QTextTableFormat:: setAlignment ( Qt::Alignment alignment )

Sets the table's alignment .

另请参阅 alignment ().

void QTextTableFormat:: setCellPadding ( qreal padding )

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

另请参阅 cellPadding ().

void QTextTableFormat:: setCellSpacing ( qreal spacing )

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

另请参阅 cellSpacing ().

void QTextTableFormat:: setColumnWidthConstraints (const QVector < QTextLength > & constraints )

Sets the column width constraints for the table.

另请参阅 columnWidthConstraints () 和 clearColumnWidthConstraints ().

void QTextTableFormat:: setHeaderRowCount ( int count )

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.

该函数在 Qt 4.2 引入。

另请参阅 headerRowCount ().