我正在编写复杂的富文本编辑器,派生自QTextEdit
类。它必须能够插入,调整大小,并将各种格式应用于嵌入表格。如何更改QTextTable中的行高度
我找到了设置列宽的函数(setColumnWidthConstraints)。 但是没有人去change _rows_ heights
。
有什么办法可以达到这个目的吗?
示例代码:
void CustomTextEdit::insertTable (int rows_cnt, int columns_cnt)
{
QTextCursor cursor = textCursor();
QTextTableFormat table_format;
table_format.setCellPadding (5);
// TODO: This call just changed the frame border height, not table itself.
//table_format.setHeight (50);
// Setup columns widths - all is working perfectly.
QVector <QTextLength> col_widths;
for (int i = 0; i < columns_cnt; ++i)
col_widths << QTextLength (QTextLength::PercentageLength, 100.0/columns_cnt);
table_format.setColumnWidthConstraints (col_widths);
// ...But there is no similar function as setRowHeighConstraints for rows!
// Insert our table with specified format settings
cursor.insertTable (rows_cnt, columns_cnt, table_format);
}
你可以使用QTextFrameFormat ::自动调用setHeight( qreal高度) – 2013-03-20 10:32:32
@Cool_Coder这只是改变了框架的高度(即将显示边框的位置)。但我需要指定表格的任何单独行的高度。 – eraxillan 2013-03-20 11:24:18
可以请显示一些代码,以便我可以对此发表评论? – 2013-03-20 11:31:47