QTextTable Class Reference

[QtGui module]

该QTextTable类表示一个表QTextDocumentMore…

继承QTextFrame

Methods

  • __init__ (self, QTextDocument doc)
  • appendColumns (self, int count)
  • appendRows (self, int count)
  • QTextTableCell cellAt (self, int row, int col)
  • QTextTableCell cellAt (self, int position)
  • QTextTableCell cellAt (self, QTextCursor c)
  • int columns (self)
  • QTextTableFormat format (self)
  • insertColumns (self, int pos, int num)
  • insertRows (self, int pos, int num)
  • mergeCells (self, int row, int col, int numRows, int numCols)
  • mergeCells (self, QTextCursor cursor)
  • removeColumns (self, int pos, int num)
  • removeRows (self, int pos, int num)
  • resize (self, int rows, int cols)
  • QTextCursor rowEnd (self, QTextCursor c)
  • int rows (self)
  • QTextCursor rowStart (self, QTextCursor c)
  • setFormat (self, QTextTableFormat aformat)
  • splitCell (self, int row, int col, int numRows, int numCols)

Detailed Description

该QTextTable类表示一个表QTextDocument

表是一组细胞有序的行和列。每个表包含至少一行和一列。每个小区包含一个块,并且是由一个帧所包围。

表通常被创建和插入到与一个文件QTextCursor.insertTable()函数。例如,我们可以使用下面的代码行在编辑器中当前光标位置插入一个表格三行两列:

  1. [QTextCursor]($docs-qtextcursor.html) cursor(editor->textCursor());
  2. cursor.movePosition([QTextCursor]($docs-qtextcursor.html).Start);
  3. QTextTable *table = cursor.insertTable(rows, columns, tableFormat);

在创建或更新版本改变时,该表与表格式要么是定义setFormat( ) 。

当前正在编辑光标找到该表与QTextCursor.currentTable( ) 。这使得它的格式或尺寸后,它已经被插入到一个文件被改变。

一个表的大小可以用改变resize() ,或者通过使用insertRows( )insertColumns( )removeRows() ,或removeColumns( ) 。使用cellAt( )来检索表格单元格。

表行的起始位置和结束位置可以通过移动光标在表内,并使用被发现rowStart()和rowEnd( )函数的开始和每一行的末端,获得游标。

一个QTextTable内的行和列可以进行合并和拆分使用的mergeCells()和splitCell()函数。然而,只有跨越多个行或列的单元可以拆分。 (合并或拆分不增加或减少的行数和列数。 )

请注意,如果你已经合并了多个列和行到一个单元格,你将无法在合并单元格拆分成跨越多个行或列新的细胞。为了能够拆分单元格跨越了你需要这样做了几个迭代若干行和列。

| Original Table | 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.

  1. table->mergeCells(0, 0, 1, 2);

| | QTextTable Class Reference - 图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.

  1. table->splitCell(0, 0, 1, 1);

| | Split Table | This results in the original table. |


Method Documentation

  1. QTextTable.__init__ (self, QTextDocument doc)
  1. QTextTable.appendColumns (self, int count)

追加可count列的右侧的表。

此功能被引入Qt的4.5 。

See also insertColumns( )insertRows( )resize( )removeRows( )removeColumns()和appendRows( ) 。

  1. QTextTable.appendRows (self, int count)

追加可count行于该表的底部。

此功能被引入Qt的4.5 。

See also insertColumns( )insertRows( )resize( )removeRows( )removeColumns()和appendColumns( ) 。

  1. QTextTableCell QTextTable.cellAt (self, int row, int col)

[

返回表格单元在给定的rowcolumn在表中。

]($docs-qtexttablecell.html)

See also columns()和rows( ) 。

  1. QTextTableCell QTextTable.cellAt (self, int position)

[

这是一个重载函数。

返回包含字符在给定的表格单元格position在文档中。

]($docs-qtexttablecell.html)

  1. QTextTableCell QTextTable.cellAt (self, QTextCursor c)

[

这是一个重载函数。

返回包含给定的表格单元格cursor

  1. int QTextTable.columns (self)

返回的列在表中的编号。

]($docs-qtexttablecell.html)

See also rows( ) 。

  1. QTextTableFormat QTextTable.format (self)

[

返回表的格式。

]($docs-qtexttableformat.html)

See also setFormat( ) 。

  1. QTextTable.insertColumns (self, int pos, int num)

插入一个编号的columns与指定的列前index

See also insertRows( )resize( )removeRows( )removeColumns( )appendRows()和appendColumns( ) 。

  1. QTextTable.insertRows (self, int pos, int num)

插入一个编号的rows具有指定的行之前index

See also resize( )insertColumns( )removeRows( )removeColumns( )appendRows()和appendColumns( ) 。

  1. QTextTable.mergeCells (self, int row, int col, int numRows, int numCols)

合并的单元格中的指定rowcolumn与相邻的细胞进入一个小区。新的细胞将跨越numRows行和numCols列。如果numRows or numCols小于行或列的单元格跨越的当前数目,则此方法不执行任何操作。

这个函数是Qt 4.1中引入。

See also splitCell( ) 。

  1. QTextTable.mergeCells (self, QTextCursor cursor)

这是一个重载函数。

合并由提供选择的单元cursor

这个函数是Qt 4.1中引入。

See also splitCell( ) 。

  1. QTextTable.removeColumns (self, int pos, int num)

除去了一些columns开始在指定的列index

See also insertRows( )insertColumns( )removeRows( )resize( )appendRows()和appendColumns( ) 。

  1. QTextTable.removeRows (self, int pos, int num)

除去了一些rows开始的行中的指定index

See also insertRows( )insertColumns( )resize( )removeColumns( )appendRows()和appendColumns( ) 。

  1. QTextTable.resize (self, int rows, int cols)

调整大小的表包含所需数量的rowscolumns

See also insertRows( )insertColumns( )removeRows()和removeColumns( ) 。

  1. QTextCursor QTextTable.rowEnd (self, QTextCursor c)

[

返回一个指针指向该行的末尾包含给定cursor

]($docs-qtextcursor.html)

See also rowStart( ) 。

  1. int QTextTable.rows (self)

返回行的表的数目。

See also columns( ) 。

  1. QTextCursor QTextTable.rowStart (self, QTextCursor c)

[

返回一个指针指向该行的开始,包含给定的cursor

]($docs-qtextcursor.html)

See also rowEnd( ) 。

  1. QTextTable.setFormat (self, QTextTableFormat aformat)

设置表的format

See also format( ) 。

  1. QTextTable.splitCell (self, int row, int col, int numRows, int numCols)

拆分在指定的单元格rowcolumn成多个细胞与指定尺寸的数组numRowsnumCols

Note:这是唯一可能的分裂跨越多行或多列的细胞,如已使用合并的行mergeCells( ) 。

这个函数是Qt 4.1中引入。

See also mergeCells( ) 。