在 QT QTextEdit 中粘贴表情符号 [英] Pasting emoji in QT QTextEdit

查看:56
本文介绍了在 QT QTextEdit 中粘贴表情符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将表情符号粘贴到 QT QTextEdit 框中,但它没有被识别并且显示为 ???或 [][]

I'm trying to paste emoji's in the QT QTextEdit box but it's not getting recognized and it's showing as ??? or [][]

我不是在谈论笑脸,我在谈论表情符号.

I'm not talking about smiley, I'm talking about emoji.

如何确保 QT 的 QTextEdit 接受表情符号并正确显示它们?

How can I go about making sure that QT's QTextEdit accepts emoji and displays them correctly?

谢谢.

根据以下有用的答案得到它:

解决方案:

    QFontDatabase fontDB;
    fontDB.addApplicationFont(":/Resources/fonts/seguisym.ttf");

    QApplication::setFont(QFont(QStringLiteral("Segoe UI Symbol")));

推荐答案

相当数量的 emoji 字符在 Unicode 标准.例如,如果您在 Mac OS X 10.9 中使用 Qt 5.3 进行开发,则在文本编辑中粘贴表情符号 字符应该像粘贴任何其他字符时一样工作.

A considerable number of emoji characters are in the Unicode Standard. If you're, for example, developing with Qt 5.3 in Mac OS X 10.9, pasting emoji characters in text edits should work as it does when pasting any other character.

您的应用程序显示 ? 和/或 [] 的原因是因为当前字体(可能是默认系统字体)不提供表情符号字符"的表示.你可以在网上找到合适的字体.检查 this 以供参考.

The reason why your application is showing ?'s and/or []'s is because the current font (perhaps the default system font) doesn't provide representations for emoji "characters". You can find a proper font out there in the web. Check this for reference.

然后您可以将字体添加到您的 Qt 应用程序中

Then you can add the font to your Qt application

QFontDatabase fontDB;
fontDB.addApplicationFont(":/A Font Supporting Emoji.ttf");

并将其设置为您的应用程序的字体,或者如果您愿意,也可以仅将其设置为您的 QTextEdit

and set it as the font for your application or only your QTextEdit if you prefer

setFont(QFont(QStringLiteral("A Font Supporting Emoji")));

有了这个,您的应用应该能够显示表情符号.

With this your app should be able to display emoji.

这篇关于在 QT QTextEdit 中粘贴表情符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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