QtBase
v6.3.1
|
The QTextTable class represents a table in a QTextDocument. \inmodule QtGui. More...
#include <qtexttable.h>
Friends | |
class | QTextTableCell |
The QTextTable class represents a table in a QTextDocument. \inmodule QtGui.
\reentrant
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, and is surrounded by a frame.
Tables are usually created and inserted into a document with the QTextCursor::insertTable() function. For example, we can insert a table with three rows and two columns at the current cursor position in an editor using the following lines of code:
\codeline
The table format is either defined when the table is created or changed later with setFormat().
The table currently being edited by the cursor is found with QTextCursor::currentTable(). This allows its format or dimensions to be changed after it has been inserted into a document.
A table's size can be changed with resize(), or by using insertRows(), insertColumns(), removeRows(), or removeColumns(). Use cellAt() to retrieve table cells.
The starting and ending positions of table rows can be found by moving a cursor within a table, and using the rowStart() and rowEnd() functions to obtain cursors at the start and end of each row.
Rows and columns within a QTextTable can be merged and split using the mergeCells() and splitCell() functions. However, only cells that span multiple rows or columns can be split. (Merging or splitting does not increase or decrease the number of rows and columns.)
Note that if you have merged multiple columns and rows into one cell, you will not be able to split the merged cell into new cells spanning over more than one row or column. To be able to split cells spanning over several rows and columns you need to do this over several iterations.
\table 80% \row
Definition at line 98 of file qtexttable.h.
|
explicit |
Definition at line 559 of file qtexttable.cpp.
QTextTable::~QTextTable | ( | ) |
Definition at line 568 of file qtexttable.cpp.
void QTextTable::appendColumns | ( | int | count | ) |
Definition at line 848 of file qtexttable.cpp.
void QTextTable::appendRows | ( | int | count | ) |
Definition at line 837 of file qtexttable.cpp.
QTextTableCell QTextTable::cellAt | ( | const QTextCursor & | cursor | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns the table cell containing the given cursor.
Definition at line 624 of file qtexttable.cpp.
QTextTableCell QTextTable::cellAt | ( | int | position | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns the table cell that contains the character at the given position in the document.
Definition at line 598 of file qtexttable.cpp.
QTextTableCell QTextTable::cellAt | ( | int | row, |
int | column | ||
) | const |
Returns the table cell at the given row and column in the table.
Definition at line 580 of file qtexttable.cpp.
int QTextTable::columns | ( | ) | const |
Returns the number of columns in the table.
Definition at line 1262 of file qtexttable.cpp.
|
inline |
Returns the table's format.
Definition at line 128 of file qtexttable.h.
void QTextTable::insertColumns | ( | int | index, |
int | columns | ||
) |
Inserts a number of columns before the column with the specified index.
Definition at line 736 of file qtexttable.cpp.
void QTextTable::insertRows | ( | int | index, |
int | rows | ||
) |
Inserts a number of rows before the row with the specified index.
Definition at line 670 of file qtexttable.cpp.
void QTextTable::mergeCells | ( | const QTextCursor & | cursor | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Merges the cells selected by the provided cursor.
Definition at line 1156 of file qtexttable.cpp.
void QTextTable::mergeCells | ( | int | row, |
int | column, | ||
int | numRows, | ||
int | numCols | ||
) |
Merges the cell at the specified row and column with the adjacent cells into one cell. The new cell will span numRows rows and numCols columns. This method does nothing if numRows or numCols is less than the current number of rows or columns spanned by the cell.
Definition at line 996 of file qtexttable.cpp.
void QTextTable::removeColumns | ( | int | index, |
int | columns | ||
) |
Removes a number of columns starting with the column at the specified index.
Definition at line 922 of file qtexttable.cpp.
void QTextTable::removeRows | ( | int | index, |
int | rows | ||
) |
Removes a number of rows starting with the row at the specified index.
Definition at line 860 of file qtexttable.cpp.
void QTextTable::resize | ( | int | rows, |
int | columns | ||
) |
Resizes the table to contain the required number of rows and columns.
Definition at line 636 of file qtexttable.cpp.
QTextCursor QTextTable::rowEnd | ( | const QTextCursor & | cursor | ) | const |
Returns a cursor pointing to the end of the row that contains the given cursor.
Definition at line 1300 of file qtexttable.cpp.
int QTextTable::rows | ( | ) | const |
Returns the number of rows in the table.
Definition at line 1248 of file qtexttable.cpp.
QTextCursor QTextTable::rowStart | ( | const QTextCursor & | cursor | ) | const |
Returns a cursor pointing to the start of the row that contains the given cursor.
Definition at line 1279 of file qtexttable.cpp.
void QTextTable::setFormat | ( | const QTextTableFormat & | format | ) |
Sets the table's format.
Definition at line 1321 of file qtexttable.cpp.
void QTextTable::splitCell | ( | int | row, |
int | column, | ||
int | numRows, | ||
int | numCols | ||
) |
Splits the specified cell at row and column into an array of multiple cells with dimensions specified by numRows and numCols.
Definition at line 1177 of file qtexttable.cpp.
|
friend |
Definition at line 133 of file qtexttable.h.