我正在編寫複雜的富文本編輯器,派生自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