【发布时间】:2015-05-14 21:05:55
【问题描述】:
我想在 QLineEdit 字段中使用放大镜 (U+1F50E) Unicode 符号。 我想出了如何使用 QChar 使用 16 位 unicode 符号,但是我不知道如何使用由 5 个十六进制数字表示的 unicode 符号。
QLineEdit edit = new QLineEdit();
edit.setFont(QFont("Segoe UI Symbol"));
edit.setText(????);
到目前为止我已经尝试过:
edit.setText(QString::fromUtf8("\U0001F50E"));
这给了编译器警告:
warning C4566: character represented by universal-character-name '\UD83DDD0E' cannot be represented in the current code page
并显示为:??
我也试过了:
edit.setText(QString("\U0001F50E"));
这给了编译器警告:
warning C4566: character represented by universal-character-name '\UD83DDD0E' cannot be represented in the current code page (1252)
还给了:??
我尝试了所有可以尝试使用 QChar 的方法。我还尝试切换我的 CPP 文件的编码并复制并粘贴符号,但没有成功。
【问题讨论】:
-
^ 这是一个类似的问题,但答案对我一点帮助都没有
-
由于您使用的是字符串文字,您是否尝试过使用QStringLiteral macro?
标签: c++ qt unicode encoding qt4