0
点赞
收藏
分享

微信扫一扫

2.从hello world开始【go】

phpworkerman 04-01 15:00 阅读 1

Qt中支持HTML的控件有textEdit 、label 、textBrowser 。

接口:setHtml("Qt"); toHtml().

文本样式设置  :

可分字设置 ,主要使用QTextCharFormat类进行文本样式设置。

示例:

QTextCharFormat fmt;

//粗体

fmt.setFontWeight(QFont::Bold);

//斜体

fmt.setFontItalic(true);

//下划线

fmt.setFontUnderline(true);

//颜色

fmt.setForeground(color);

//字体 QFont

fmt.setFont(ft);

//最后 合并样式

mergeFormat(fmt);

void mergeFormat(const QTextCharFormat &format)
{
    QTextCursor cursor = textEdit->textCursor();
    if (!cursor.hasSelection())
        cursor.select(QTextCursor::WordUnderCursor);
    cursor.mergeCharFormat(format);
    textEdit->mergeCurrentCharFormat(format);
}

举报

相关推荐

0 条评论