PySide6.QtGui.QTextTableCell¶
- class QTextTableCell¶
QTextTableCell
类表示QTextTable
中单元格的属性。更多…概要¶
方法¶
def
__init__()
def
begin()
def
column()
def
columnSpan()
def
end()
def
firstPosition()
def
format()
def
isValid()
def
lastPosition()
def
__ne__()
def
__eq__()
def
row()
def
rowSpan()
def
setFormat()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
表格单元格是属于表格的文档结构的一部分。表格将单元格排列成特定的行和列;单元格也可以跨越多个列和行。
单元格通常在通过
insertTable()
将表格插入文档时创建,但在调整表格大小时也会创建和销毁单元格。单元格包含有关其在表格中位置的信息;您可以获取单元格的
row()
和column()
编号,以及其rowSpan()
和columnSpan()
。单元格的
format()
描述了其内容的默认字符格式。firstCursorPosition()
和lastCursorPosition()
函数用于获取单元格在文档中的范围。- __init__()¶
构造一个无效的表格单元格。
另请参阅
- __init__(o)
- Parameters:
o –
QTextTableCell
复制构造函数。基于
other
单元格创建一个新的QTextTableCell
对象。返回一个指向表格单元格开头的帧迭代器。
另请参阅
- column()¶
- Return type:
整数
返回包含此单元格的表格中的列号。
另请参阅
- columnSpan()¶
- Return type:
整数
返回此单元格跨越的列数。默认值为1。
另请参阅
返回一个指向表格单元格末尾的帧迭代器。
另请参阅
- firstCursorPosition()¶
- Return type:
返回此单元格中的第一个有效光标位置。
另请参阅
- firstPosition()¶
- Return type:
整数
- format()¶
- Return type:
返回单元格的字符格式。
另请参阅
- isValid()¶
- Return type:
布尔
如果这是一个有效的表格单元格,则返回
true
;否则返回false。- lastCursorPosition()¶
- Return type:
返回此单元格中最后一个有效的光标位置。
- lastPosition()¶
- Return type:
整数
- __ne__(other)¶
- Parameters:
其他 –
QTextTableCell
- Return type:
布尔
如果此单元格对象和
other
单元格对象描述的是不同的单元格,则返回true
;否则返回false
。- __eq__(other)¶
- Parameters:
其他 –
QTextTableCell
- Return type:
布尔
如果此单元格对象和
other
单元格对象描述的是同一个单元格,则返回true
;否则返回false
。- row()¶
- Return type:
整数
返回包含此单元格的表格中的行号。
另请参阅
- rowSpan()¶
- Return type:
整数
返回此单元格跨越的行数。默认值为1。
另请参阅
- setFormat(format)¶
- Parameters:
format –
QTextCharFormat
将单元格的字符格式设置为
format
。例如,这可以用于更改整个单元格的背景颜色:QTextTableCell cell = table->cellAt(2, 3); QTextCharFormat format = cell.format(); format.setBackground(Qt::blue); cell.setFormat(format);
请注意,单元格的行或列跨度不能通过此函数更改。您必须使用
mergeCells
和splitCell
来代替。另请参阅
- tableCellFormatIndex()¶
- Return type:
整数
返回表格单元格格式在文档内部格式列表中的索引。
另请参阅