Qt:Документация 4.3.2/qtexttable

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QTextTable Class Reference
[модуль QtGui ]

The QTextTable class represents a table in a QTextDocument. Далее...

 #include <QTextTable>

Inherits QTextFrame.

[править] Открытые функции

  • QTextTableCell cellAt ( int row, int column ) const
  • QTextTableCell cellAt ( int position ) const
  • QTextTableCell cellAt ( const QTextCursor & cursor ) const
  • int columns () const
  • QTextTableFormat format () const
  • void insertColumns ( int index, int columns )
  • void insertRows ( int index, int rows )
  • void mergeCells ( int row, int column, int numRows, int numCols )
  • void mergeCells ( const QTextCursor & cursor )
  • void removeColumns ( int index, int columns )
  • void removeRows ( int index, int rows )
  • void resize ( int rows, int columns )
  • QTextCursor rowEnd ( const QTextCursor & cursor ) const
  • QTextCursor rowStart ( const QTextCursor & cursor ) const
  • int rows () const
  • void setFormat ( const QTextTableFormat & format )
  • void splitCell ( int row, int column, int numRows, int numCols )
  • 10 public functions inherited from QTextFrame
  • 4 public functions inherited from QTextObject
  • 29 открытых функций, унаследованных от QObject

[править] Дополнительные унаследованные члены

  • 1 свойство, унаследованное от QObject
  • 1 открытый слот, унаследованный от QObject
  • 1 сигнал, унаследованный от QObject
  • 5 статических открытых членов, унаследованных от QObject
  • 1 protected function inherited from QTextObject
  • 7 защищенных функций, унаследованных от QObject

[править] Подробное описание

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.)


Файл:Texttable-split.png 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);
Файл:Texttable-merge.png 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);
Файл:Texttable-split.png This results in the original table.

See also QTextTableFormat.


[править] Описание функций-членов

[править]
QTextTableCell QTextTable::cellAt ( int row, int column ) const

Returns the table cell at the given row and column in the table.

See also columns() and rows().

[править]
QTextTableCell QTextTable::cellAt ( int position ) const

Эта перегруженная функция предоставлена для удобства.

Returns the table cell that contains the character at the given position in the document.

[править]
QTextTableCell QTextTable::cellAt ( const QTextCursor & cursor ) const

Эта перегруженная функция предоставлена для удобства.

Returns the table cell containing the given cursor.

[править]
int QTextTable::columns () const

Returns the number of columns in the table.

See also rows().

[править]
QTextTableFormat QTextTable::format () const

Returns the table's format.

See also setFormat().

[править]
void QTextTable::insertColumns ( int index, int columns )

Inserts a number of columns before the column with the specified index.

See also insertRows(), resize(), removeRows(), and removeColumns().

[править]
void QTextTable::insertRows ( int index, int rows )

Inserts a number of rows before the row with the specified index.

See also resize(), insertColumns(), removeRows(), and removeColumns().

[править]
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. If numRows or numCols is less than the current number of rows or columns the cell spans then this method does nothing.

Эта функция была введена в Qt 4.1.

See also splitCell().

[править]
void QTextTable::mergeCells ( const QTextCursor & cursor )

Эта перегруженная функция предоставлена для удобства.

Merges the cells selected by the provided cursor.

Эта функция была введена в Qt 4.1.

See also splitCell().

[править]
void QTextTable::removeColumns ( int index, int columns )

Removes a number of columns starting with the column at the specified index.

See also insertRows(), insertColumns(), removeRows(), and resize().

[править]
void QTextTable::removeRows ( int index, int rows )

Removes a number of rows starting with the row at the specified index.

See also insertRows(), insertColumns(), resize(), and removeColumns().

[править]
void QTextTable::resize ( int rows, int columns )

Resizes the table to contain the required number of rows and columns.

See also insertRows(), insertColumns(), removeRows(), and removeColumns().

[править]
QTextCursor QTextTable::rowEnd ( const QTextCursor & cursor ) const

Returns a cursor pointing to the end of the row that contains the given cursor.

See also rowStart().

[править]
QTextCursor QTextTable::rowStart ( const QTextCursor & cursor ) const

Returns a cursor pointing to the start of the row that contains the given cursor.

See also rowEnd().

[править]
int QTextTable::rows () const

Returns the number of rows in the table.

See also columns().

[править]
void QTextTable::setFormat ( const QTextTableFormat & format )

Sets the table's format.

See also format().

[править]
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.

Note: It is only possible to split cells that span multiple rows or columns, such as rows that have been merged using mergeCells().

Эта функция была введена в Qt 4.1.

See also mergeCells().



Copyright © 2007 Trolltech Trademarks
Qt 4.3.2