|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QTextObject
com.trolltech.qt.gui.QTextFrame
com.trolltech.qt.gui.QTextTable
public class QTextTable
The QTextTable class represents a table 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, 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:
QTextCursor cursor(editor->textCursor()); cursor.movePosition(QTextCursor::Start); QTextTable *table = cursor.insertTable(rows, columns, tableFormat);
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.)
![]() | Suppose we have a 2x6 table of names and addresses. To merge both columns in the first row we invoke mergeCells with row = 0, column = 0, numRows = 1 and numColumns = 2.table->mergeCells(0, 0, 1, 2); |
![]() | This gives us the following table. To split the first row of the table back into two cells, we invoke the splitCell function with numRows and numCols = 1.table->splitCell(0, 0, 1, 1); |
![]() | This results in the original table. |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Constructor Summary | |
---|---|
QTextTable(QTextDocument doc)
|
Method Summary | |
---|---|
QTextTableCell |
cellAt(int position)
Returns the table cell that contains the character at the given position in the document. |
QTextTableCell |
cellAt(int row,
int col)
Returns the table cell at the given row and col in the table. |
QTextTableCell |
cellAt(QTextCursor c)
Returns the table cell containing the given c. |
int |
columns()
Returns the number of columns in the table. |
static QTextTable |
fromNativePointer(QNativePointer nativePointer)
This function returns the QTextTable instance pointed to by nativePointer |
void |
insertColumns(int pos,
int num)
Inserts a number of num before the column with the specified pos. |
void |
insertRows(int pos,
int num)
Inserts a number of num before the row with the specified pos. |
void |
mergeCells(int row,
int col,
int numRows,
int numCols)
Merges the cell at the specified row and col with the adjacent cells into one cell. |
void |
mergeCells(QTextCursor cursor)
Merges the cells selected by the provided cursor. |
void |
removeColumns(int pos,
int num)
Removes a number of num starting with the column at the specified pos. |
void |
removeRows(int pos,
int num)
Removes a number of num starting with the row at the specified pos. |
void |
resize(int rows,
int cols)
Resizes the table to contain the required number of rows and cols. |
QTextCursor |
rowEnd(QTextCursor c)
Returns a cursor pointing to the end of the row that contains the given c. |
int |
rows()
Returns the number of rows in the table. |
QTextCursor |
rowStart(QTextCursor c)
Returns a cursor pointing to the start of the row that contains the given c. |
void |
setFormat(QTextTableFormat format)
Sets the table's format. |
void |
splitCell(int row,
int col,
int numRows,
int numCols)
Splits the specified cell at row and col into an array of multiple cells with dimensions specified by numRows and numCols. |
QTextTableFormat |
tableFormat()
Returns the table's format. |
Methods inherited from class com.trolltech.qt.gui.QTextFrame |
---|
begin, childFrames, end, firstCursorPosition, firstPosition, frameFormat, lastCursorPosition, lastPosition, parentFrame, setFrameFormat |
Methods inherited from class com.trolltech.qt.gui.QTextObject |
---|
document, format, formatIndex, objectIndex, setFormat |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
disconnect, disconnect, signalSender |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QTextTable(QTextDocument doc)
Method Detail |
---|
public final QTextTableCell cellAt(QTextCursor c)
Returns the table cell containing the given c.
public final QTextTableCell cellAt(int row, int col)
Returns the table cell at the given row and col in the table.
public final QTextTableCell cellAt(int position)
Returns the table cell that contains the character at the given position in the document.
public final int columns()
Returns the number of columns in the table.
public final QTextTableFormat tableFormat()
Returns the table's format.
public final void insertColumns(int pos, int num)
Inserts a number of num before the column with the specified pos.
public final void insertRows(int pos, int num)
Inserts a number of num before the row with the specified pos.
public final void mergeCells(QTextCursor cursor)
Merges the cells selected by the provided cursor.
public final void mergeCells(int row, int col, int numRows, int numCols)
Merges the cell at the specified row and col with the adjacent cells into one cell. The new cell will span numRows rows and numCols columns. If numRows or numCols is less than the current number of rows or columns the cell spans then this method does nothing.
public final void removeColumns(int pos, int num)
Removes a number of num starting with the column at the specified pos.
public final void removeRows(int pos, int num)
Removes a number of num starting with the row at the specified pos.
public final void resize(int rows, int cols)
Resizes the table to contain the required number of rows and cols.
public final QTextCursor rowEnd(QTextCursor c)
Returns a cursor pointing to the end of the row that contains the given c.
public final QTextCursor rowStart(QTextCursor c)
Returns a cursor pointing to the start of the row that contains the given c.
public final int rows()
Returns the number of rows in the table.
public final void setFormat(QTextTableFormat format)
Sets the table's format.
public final void splitCell(int row, int col, int numRows, int numCols)
Splits the specified cell at row and col into an array of multiple cells with dimensions specified by numRows and numCols.
Note: It is only possible to split cells that span multiple rows or columns, such as rows that have been merged using mergeCells.
public static QTextTable fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |