QTextTableFormat Class

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

Header: #include <QTextTableFormat>
qmake: QT += gui
Inherits: QTextFrameFormat

Note: All functions in this class are reentrant.

Public Functions

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 setColumns(int columns)
void setHeaderRowCount(int count)

Protected Functions

QTextTableFormat(const QTextFormat &fmt)

Detailed Description

The QTextTableFormat class provides formatting information for tables in a 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). 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 vector containing new constraints. If no constraints are required, clearColumnWidthConstraints() can be used to remove them.

See also QTextTable, QTextTableCell, and QTextLength.

Member Function Documentation

QTextTableFormat::QTextTableFormat()

Default constructs an instance of QTextTableFormat.

[protected] QTextTableFormat::QTextTableFormat(const QTextFormat &fmt)

Default constructs an instance of QTextTableFormat.

Qt::Alignment QTextTableFormat::alignment() const

See also setAlignment().

qreal QTextTableFormat::cellPadding() const

See also setCellPadding().

qreal QTextTableFormat::cellSpacing() const

See also setCellSpacing().

void QTextTableFormat::clearColumnWidthConstraints()

QVector<QTextLength> QTextTableFormat::columnWidthConstraints() const

See also setColumnWidthConstraints().

int QTextTableFormat::columns() const

See also setColumns().

int QTextTableFormat::headerRowCount() const

See also setHeaderRowCount().

bool QTextTableFormat::isValid() const

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

See also alignment().

void QTextTableFormat::setCellPadding(qreal padding)

See also cellPadding().

void QTextTableFormat::setCellSpacing(qreal spacing)

See also cellSpacing().

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

See also columnWidthConstraints().

void QTextTableFormat::setColumns(int columns)

See also columns().

void QTextTableFormat::setHeaderRowCount(int count)

See also headerRowCount().