<class name="QTextTable" doc="/** <p>The <a href="QTextTable.html#QTextTable(com.trolltech.qt.gui.QTextDocument)"><tt>QTextTable</tt></a> class represents a table in a <a href="QTextDocument.html"><tt>QTextDocument</tt></a>.</p> <p>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.</p> <p>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:</p> <pre> QTextCursor cursor(editor-&gt;textCursor()); cursor.movePosition(QTextCursor::Start); QTextTable *table = cursor.insertTable(rows, columns, tableFormat);</pre> <p>The table format is either defined when the table is created or changed later with <a href="QTextTable.html#setFormat(com.trolltech.qt.gui.QTextTableFormat)"><tt>setFormat</tt></a>.</p> <p>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.</p> <p>A table's size can be changed with <a href="QTextTable.html#resize(int, int)"><tt>resize</tt></a>, or by using <a href="QTextTable.html#insertRows(int, int)"><tt>insertRows</tt></a>, <a href="QTextTable.html#insertColumns(int, int)"><tt>insertColumns</tt></a>, <a href="QTextTable.html#removeRows(int, int)"><tt>removeRows</tt></a>, or <a href="QTextTable.html#removeColumns(int, int)"><tt>removeColumns</tt></a>. Use <a href="QTextTable.html#cellAt(int)"><tt>cellAt</tt></a> to retrieve table cells.</p> <p>The starting and ending positions of table rows can be found by moving a cursor within a table, and using the <a href="QTextTable.html#rowStart(com.trolltech.qt.gui.QTextCursor)"><tt>rowStart</tt></a> and <a href="QTextTable.html#rowEnd(com.trolltech.qt.gui.QTextCursor)"><tt>rowEnd</tt></a> functions to obtain cursors at the start and end of each row.</p> <p>Rows and columns within a <a href="QTextTable.html#QTextTable(com.trolltech.qt.gui.QTextDocument)"><tt>QTextTable</tt></a> can be merged and split using the <a href="QTextTable.html#mergeCells(int, int, int, int)"><tt>mergeCells</tt></a> and <a href="QTextTable.html#splitCell(int, int, int, int)"><tt>splitCell</tt></a> 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.)</p> <p><table width="80%" align="center" cellpadding="2" cellspacing="1" border="0"> <tr valign="top" class="odd"><td><img src="%2E%2E/images/texttable-split.png" alt="Original Table" /></td><td>Suppose we have a 2x6 table of names and addresses. To merge both columns in the first row we invoke <a href="QTextTable.html#mergeCells(int, int, int, int)"><tt>mergeCells</tt></a> with <tt>row</tt> = 0, <tt>column</tt> = 0, <tt>numRows</tt> = 1 and <tt>numColumns</tt> = 2.<pre> table-&gt;mergeCells(0, 0, 1, 2);</pre> </td></tr> <tr valign="top" class="even"><td><img src="%2E%2E/images/texttable-merge.png" /></td><td>This gives us the following table. To split the first row of the table back into two cells, we invoke the <a href="QTextTable.html#splitCell(int, int, int, int)"><tt>splitCell</tt></a> function with <tt>numRows</tt> and <tt>numCols</tt> = 1.<pre> table-&gt;splitCell(0, 0, 1, 1);</pre> </td></tr> <tr valign="top" class="odd"><td><img src="%2E%2E/images/texttable-split.png" alt="Split Table" /></td><td>This results in the original table.</td></tr> </table></p> @see <a href="QTextTableFormat.html"><tt>QTextTableFormat</tt></a> */"> <method name="public QTextTable(com.trolltech.qt.gui.QTextDocument doc)" doc="/** <p>This method is used internally by Qt Jambi. Do not use it in your applications.</p> */"/> <method name="public final com.trolltech.qt.gui.QTextTableCell cellAt(com.trolltech.qt.gui.QTextCursor c)" doc="/** <p>Returns the table cell containing the given <tt>c</tt>.</p> */"/> <method name="public final com.trolltech.qt.gui.QTextTableCell cellAt(int row, int col)" doc="/** <p>Returns the table cell at the given <tt>row</tt> and <tt>col</tt> in the table.</p> @see <a href="QTextTable.html#columns()"><tt>columns</tt></a> @see <a href="QTextTable.html#rows()"><tt>rows</tt></a> */"/> <method name="public final com.trolltech.qt.gui.QTextTableCell cellAt(int position)" doc="/** <p>Returns the table cell that contains the character at the given <tt>position</tt> in the document.</p> */"/> <method name="public final int columns()" doc="/** <p>Returns the number of columns in the table.</p> @see <a href="QTextTable.html#rows()"><tt>rows</tt></a> */"/> <method name="public final com.trolltech.qt.gui.QTextTableFormat tableFormat()" doc="/** <p>Returns the table's format.</p> @see <a href="QTextTable.html#setFormat(com.trolltech.qt.gui.QTextTableFormat)"><tt>setFormat</tt></a> */"/> <method name="public final void insertColumns(int pos, int num)" doc="/** <p>Inserts a number of <tt>num</tt> before the column with the specified <tt>pos</tt>.</p> @see <a href="QTextTable.html#insertRows(int, int)"><tt>insertRows</tt></a> @see <a href="QTextTable.html#resize(int, int)"><tt>resize</tt></a> @see <a href="QTextTable.html#removeRows(int, int)"><tt>removeRows</tt></a> @see <a href="QTextTable.html#removeColumns(int, int)"><tt>removeColumns</tt></a> */"/> <method name="public final void insertRows(int pos, int num)" doc="/** <p>Inserts a number of <tt>num</tt> before the row with the specified <tt>pos</tt>.</p> @see <a href="QTextTable.html#resize(int, int)"><tt>resize</tt></a> @see <a href="QTextTable.html#insertColumns(int, int)"><tt>insertColumns</tt></a> @see <a href="QTextTable.html#removeRows(int, int)"><tt>removeRows</tt></a> @see <a href="QTextTable.html#removeColumns(int, int)"><tt>removeColumns</tt></a> */"/> <method name="public final void mergeCells(com.trolltech.qt.gui.QTextCursor cursor)" doc="/** <p>Merges the cells selected by the provided <tt>cursor</tt>.</p> @see <a href="QTextTable.html#splitCell(int, int, int, int)"><tt>splitCell</tt></a> */"/> <method name="public final void mergeCells(int row, int col, int numRows, int numCols)" doc="/** <p>Merges the cell at the specified <tt>row</tt> and <tt>col</tt> with the adjacent cells into one cell. The new cell will span <tt>numRows</tt> rows and <tt>numCols</tt> columns. If <tt>numRows</tt> or <tt>numCols</tt> is less than the current number of rows or columns the cell spans then this method does nothing.</p> @see <a href="QTextTable.html#splitCell(int, int, int, int)"><tt>splitCell</tt></a> */"/> <method name="public final void removeColumns(int pos, int num)" doc="/** <p>Removes a number of <tt>num</tt> starting with the column at the specified <tt>pos</tt>.</p> @see <a href="QTextTable.html#insertRows(int, int)"><tt>insertRows</tt></a> @see <a href="QTextTable.html#insertColumns(int, int)"><tt>insertColumns</tt></a> @see <a href="QTextTable.html#removeRows(int, int)"><tt>removeRows</tt></a> @see <a href="QTextTable.html#resize(int, int)"><tt>resize</tt></a> */"/> <method name="public final void removeRows(int pos, int num)" doc="/** <p>Removes a number of <tt>num</tt> starting with the row at the specified <tt>pos</tt>.</p> @see <a href="QTextTable.html#insertRows(int, int)"><tt>insertRows</tt></a> @see <a href="QTextTable.html#insertColumns(int, int)"><tt>insertColumns</tt></a> @see <a href="QTextTable.html#resize(int, int)"><tt>resize</tt></a> @see <a href="QTextTable.html#removeColumns(int, int)"><tt>removeColumns</tt></a> */"/> <method name="public final void resize(int rows, int cols)" doc="/** <p>Resizes the table to contain the required number of <tt>rows</tt> and <tt>cols</tt>.</p> @see <a href="QTextTable.html#insertRows(int, int)"><tt>insertRows</tt></a> @see <a href="QTextTable.html#insertColumns(int, int)"><tt>insertColumns</tt></a> @see <a href="QTextTable.html#removeRows(int, int)"><tt>removeRows</tt></a> @see <a href="QTextTable.html#removeColumns(int, int)"><tt>removeColumns</tt></a> */"/> <method name="public final com.trolltech.qt.gui.QTextCursor rowEnd(com.trolltech.qt.gui.QTextCursor c)" doc="/** <p>Returns a cursor pointing to the end of the row that contains the given <tt>c</tt>.</p> @see <a href="QTextTable.html#rowStart(com.trolltech.qt.gui.QTextCursor)"><tt>rowStart</tt></a> */"/> <method name="public final com.trolltech.qt.gui.QTextCursor rowStart(com.trolltech.qt.gui.QTextCursor c)" doc="/** <p>Returns a cursor pointing to the start of the row that contains the given <tt>c</tt>.</p> @see <a href="QTextTable.html#rowEnd(com.trolltech.qt.gui.QTextCursor)"><tt>rowEnd</tt></a> */"/> <method name="public final int rows()" doc="/** <p>Returns the number of rows in the table.</p> @see <a href="QTextTable.html#columns()"><tt>columns</tt></a> */"/> <method name="public final void setFormat(com.trolltech.qt.gui.QTextTableFormat format)" doc="/** <p>Sets the table's <tt>format</tt>.</p> @see <a href="QTextObject.html#format()"><tt>format</tt></a> */"/> <method name="public final void splitCell(int row, int col, int numRows, int numCols)" doc="/** <p>Splits the specified cell at <tt>row</tt> and <tt>col</tt> into an array of multiple cells with dimensions specified by <tt>numRows</tt> and <tt>numCols</tt>.</p> <p><b>Note:</b> It is only possible to split cells that span multiple rows or columns, such as rows that have been merged using <a href="QTextTable.html#mergeCells(int, int, int, int)"><tt>mergeCells</tt></a>.</p> @see <a href="QTextTable.html#mergeCells(int, int, int, int)"><tt>mergeCells</tt></a> */"/> </class>