|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.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 = new QTextCursor(editor.textCursor()); cursor.movePosition(QTextCursor.MoveOperation.Start);The table format is either defined when the table is created or changed later with
QTextTable table = cursor.insertTable(rows, columns, tableFormat);
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 2x3 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. |
QTextTableFormat
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary |
---|
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Method Summary | |
---|---|
void |
appendColumns(int count)
Appends count columns at the right side of the table. |
void |
appendRows(int count)
Appends count rows at the bottom of the table. |
QTextTableCell |
cellAt(int position)
This is an overloaded member function, provided for convenience. |
QTextTableCell |
cellAt(int row,
int col)
Returns the table cell at the given row and column in the table. |
QTextTableCell |
cellAt(QTextCursor c)
This is an overloaded member function, provided for convenience. |
int |
columns()
Returns the number of columns in the table. |
void |
insertColumns(int pos,
int num)
Inserts a number of columns before the column with the specified index. |
void |
insertRows(int pos,
int num)
Inserts a number of rows before the row with the specified index. |
void |
mergeCells(int row,
int col,
int numRows,
int numCols)
Merges the cell at the specified row and column with the adjacent cells into one cell. |
void |
mergeCells(QTextCursor cursor)
This is an overloaded member function, provided for convenience. |
void |
removeColumns(int pos,
int num)
Removes a number of columns starting with the column at the specified index. |
void |
removeRows(int pos,
int num)
Removes a number of rows starting with the row at the specified index. |
void |
resize(int rows,
int cols)
Resizes the table to contain the required number of rows and columns. |
QTextCursor |
rowEnd(QTextCursor c)
Returns a cursor pointing to the end of the row that contains the given cursor. |
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 cursor. |
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 column 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 |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Method Detail |
---|
public final void appendColumns(int count)
insertColumns()
, insertRows()
, resize()
, removeRows()
, removeColumns()
, and appendRows()
.
public final void appendRows(int count)
insertColumns()
, insertRows()
, resize()
, removeRows()
, removeColumns()
, and appendColumns()
.
public final QTextTableCell cellAt(QTextCursor c)
Returns the table cell containing the given cursor.
public final QTextTableCell cellAt(int position)
Returns the table cell that contains the character at the given position in the document.
public final QTextTableCell cellAt(int row, int col)
columns()
, and rows()
.
public final int columns()
rows()
.
public final QTextTableFormat tableFormat()
setFormat()
.
public final void insertColumns(int pos, int num)
insertRows()
, resize()
, removeRows()
, removeColumns()
, appendRows()
, and appendColumns()
.
public final void insertRows(int pos, int num)
resize()
, insertColumns()
, removeRows()
, removeColumns()
, appendRows()
, and appendColumns()
.
public final void mergeCells(QTextCursor cursor)
Merges the cells selected by the provided cursor.
splitCell()
.
public final void mergeCells(int row, int col, int numRows, int numCols)
splitCell()
.
public final void removeColumns(int pos, int num)
insertRows()
, insertColumns()
, removeRows()
, resize()
, appendRows()
, and appendColumns()
.
public final void removeRows(int pos, int num)
insertRows()
, insertColumns()
, resize()
, removeColumns()
, appendRows()
, and appendColumns()
.
public final void resize(int rows, int cols)
insertRows()
, insertColumns()
, removeRows()
, and removeColumns()
.
public final QTextCursor rowEnd(QTextCursor c)
rowStart()
.
public final QTextCursor rowStart(QTextCursor c)
rowEnd()
.
public final int rows()
columns()
.
public final void setFormat(QTextTableFormat format)
public final void splitCell(int row, int col, int numRows, int numCols)
Note: It is only possible to split cells that span multiple rows or columns, such as rows that have been merged using mergeCells()
.
mergeCells()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |