小编Kha*_*ran的帖子

QTextEdit中的可点击超链接

我想使用QTextEdit(在只读模式下)显示一个可点击的超链接,我曾经这样做过

QTextEdit *textEdit = new QTextEdit;
QTextCursor cursor(textEdit->document());
textEdit->setTextCursor(cursor);
cursor->insertHtml("<a href=\"www.google.com\" >Google</a>");
textEdit->show();
Run Code Online (Sandbox Code Playgroud)

此代码会将Google显示为超链接但无法点击.
如果我用过

QTextEdit *textEdit = new QTextEdit;
QTextCursor cursor(textEdit->document());
textEdit->setTextCursor(cursor);
QTextCharFormat linkFormat = cursor.charFormat();
linkFormat.setAnchor(true);
linkFormat.setAnchorHref("http://www.google.com");
linkFormat.setAnchorName("Google");
cursor.insertText("Google", linkFormat);
Run Code Online (Sandbox Code Playgroud)

什么都没发生 "Google"只是普通文字.

请帮我插入可点击的超链接QTextEdit.

qt qtextedit

8
推荐指数
4
解决办法
4767
查看次数

在 Qt 中显示 UTF-16 笑脸

请帮助我在 Qt 中显示来自字符串“\uD83D\uDE03”的UTF-16 表情符号张开嘴的微笑的脸qDebug()”(也许使用或来QLabel显示它)。

我有:

QString a = "\\uD83D\\uDE03";
Run Code Online (Sandbox Code Playgroud)

我想将其打印到 my 中qDebug,我期望的结果是 . 我不知道该怎么做。

qt utf-16

0
推荐指数
1
解决办法
1935
查看次数

标签 统计

qt ×2

qtextedit ×1

utf-16 ×1