如何在QTextTable中改变行高 [英] How to change row height in QTextTable

查看:2281
本文介绍了如何在QTextTable中改变行高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写复杂的富文本编辑器,派生自 QTextEdit 类。它必须能够插入,调整大小,并对嵌入表应用各种格式。

I'm writing the complicated rich text editor, derived from QTextEdit class. It must be able to insert, resize, and apply various formatting to embedded tables.

我发现设置列宽的函数(setColumnWidthConstraints )。
但是没有人改变_rows_ heights

I found function for setup column widths (setColumnWidthConstraints). But there is no one to change _rows_ heights.

有没有办法实现这一点?

Is there any way to achieve this?

示例代码

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);
}


推荐答案


在样式表中使用这个函数时,样式表将只有
适用于文档中的当前块。为了在整个文档中应用样式
工作表,请改用QTextDocument :: setDefaultStyleSheet()

When using this function with a style sheet, the style sheet will only apply to the current block in the document. In order to apply a style sheet throughout a document, use QTextDocument::setDefaultStyleSheet() instead.

ref: http: //harmattan-dev.nokia.com/docs/platform-api-reference/xml/daily-docs/libqt4/qtextedit.html#insertHtml

appart从使用垫片....根据 http://harmattan-dev.nokia.com/docs/platform-api-reference/xml/daily-docs/libqt4/richtext-html-subset.html 您可以设置字体声明。

appart from using shims....according to http://harmattan-dev.nokia.com/docs/platform-api-reference/xml/daily-docs/libqt4/richtext-html-subset.html you can set the font declaration.

Qt似乎已针对CSS2.1规范,如下所示: http://www.w3.org/TR/CSS2/fonts.html#propdef-font

Qt seems to have targeted the CSS2.1 specification, which is as followed.. http://www.w3.org/TR/CSS2/fonts.html#propdef-font

您尝试在表格行中指定字体。

have you tried specifying the font within the table row.

使用insertHTML传递以下字符串,其中此字符串作为QString

pass the following string using insertHTML, where this string is delcared as a QString

<style>
table > tr {font-size: normal normal 400 12px/24px serif;}
</style>

这篇关于如何在QTextTable中改变行高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆