QTextTableCell Class
QTextTableCell 类表示QTextTable 中单元格的属性 ... 更多
头文件: | #include <QTextTableCell> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
- 所有成员(包括继承成员)的列表
- QTextTableCell 是富文本处理 API 的一部分。
注意:该类中的所有函数都是可重入的。
公共函数
QTextTableCell() | |
QTextTableCell(const QTextTableCell &other) | |
~QTextTableCell() | |
QTextFrame::iterator | begin() const |
int | column() const |
int | columnSpan() const |
QTextFrame::iterator | end() const |
QTextCursor | firstCursorPosition() const |
QTextCharFormat | format() const |
bool | isValid() const |
QTextCursor | lastCursorPosition() const |
int | row() const |
int | rowSpan() const |
void | setFormat(const QTextCharFormat &format) |
int | tableCellFormatIndex() const |
bool | operator!=(const QTextTableCell &other) const |
QTextTableCell & | operator=(const QTextTableCell &other) |
bool | operator==(const QTextTableCell &other) const |
详细说明
表格单元格是属于表格的文档结构片段。表格将单元格排序为特定的行和列;单元格也可以跨多个列和行。
通常在使用QTextCursor::insertTable() 将表格插入文档时创建单元格,但在调整表格大小时也会创建和销毁单元格。
单元格包含有关其在表格中位置的信息;您可以获取单元格的row() 和column() 数字,以及单元格的rowSpan() 和columnSpan() 数字。
单元格的format() 描述了其内容的默认字符格式。firstCursorPosition() 和lastCursorPosition() 函数用于获取单元格在文档中的范围。
另请参阅 QTextTable 和QTextTableFormat 。
成员函数文档
QTextTableCell::QTextTableCell()
构造无效的表格单元格。
另请参见 isValid()。
QTextTableCell::QTextTableCell(const QTextTableCell &other)
复制构造函数。根据other 单元创建新的 QTextTableCell 对象。
[noexcept]
QTextTableCell::~QTextTableCell()
销毁表格单元格。
QTextFrame::iterator QTextTableCell::begin() const
返回指向表格单元格起始位置的帧迭代器。
另请参见 end()。
int QTextTableCell::column() const
返回表格中包含此单元格的列的编号。
另请参阅 row()。
int QTextTableCell::columnSpan() const
返回单元格跨列数。默认为 1。
另请参阅 rowSpan()。
QTextFrame::iterator QTextTableCell::end() const
返回指向表格单元格末尾的帧迭代器。
另请参见 begin()。
QTextCursor QTextTableCell::firstCursorPosition() const
返回该单元格中第一个有效的光标位置。
另请参阅 lastCursorPosition()。
QTextCharFormat QTextTableCell::format() const
返回单元格的字符格式。
另请参阅 setFormat()。
bool QTextTableCell::isValid() const
如果这是一个有效的表格单元格,则返回true
;否则返回 false。
QTextCursor QTextTableCell::lastCursorPosition() const
返回该单元格中最后有效的光标位置。
另请参阅 firstCursorPosition()。
int QTextTableCell::row() const
返回表格中包含此单元格的行的编号。
另请参阅 column()。
int QTextTableCell::rowSpan() const
返回该单元格所跨的行数。默认为 1。
另请参阅 columnSpan()。
void QTextTableCell::setFormat(const QTextCharFormat &format)
将单元格的字符格式设置为format 。例如,这可用于更改整个单元格的背景颜色:
QTextTableCell cell = table->cellAt(2, 3); QTextCharFormat format = cell.format(); format.setBackground(Qt::blue); cell.setFormat(format);
请注意,不能通过此函数更改单元格的行跨度或列跨度。必须使用QTextTable::mergeCells 和QTextTable::splitCell 代替。
另请参见 format()。
int QTextTableCell::tableCellFormatIndex() const
返回 tableCell 格式在文档内部格式列表中的索引。
另请参见 QTextDocument::allFormats()。
bool QTextTableCell::operator!=(const QTextTableCell &other) const
如果该单元格对象和other 单元格对象描述的是不同的单元格,则返回true
;否则返回false
。
QTextTableCell &QTextTableCell::operator=(const QTextTableCell &other)
将other 表格单元格指定给该表格单元格。
bool QTextTableCell::operator==(const QTextTableCell &other) const
如果该单元格对象和other 单元格对象描述的是同一个单元格,则返回true
;否则返回false
。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.