Qt - 如何将数字转换为 QChar

标签 qt numbers char

我有一个qulonglong变量,我需要把它转换成QChar。
例如,从数字 65 我应该得到 'A'。
或者,如果有一种解决方案可以将其直接转换为 QString 也很好。

最佳答案

您需要的是 QChar构造函数。

QChar c((short) n);

注意 QChar 提供 16 位字符:

The QChar class provides a 16-bit Unicode character. In Qt, Unicode characters are 16-bit entities without any markup or structure. This class represents such an entity. It is lightweight, so it can be used everywhere. Most compilers treat it like a unsigned short.

qlonglong是一个 64 位整数,因此在转换为 short

时应该非常小心

关于Qt - 如何将数字转换为 QChar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9211304/

相关文章:

qt - 拖放窗口

c++ - 如何将 QTime 保存在 SQL Server Express 表中并读回?

c - 查找数组中 n 个数字的所有可能排列

c# - 为什么 char '\"' 与 char '"' 相同?

c++ - 如何使用引用调用从 C++ 函数中获取 char** 类型变量的值?

c++ - 如何在U盘中制作安装程序?

c++ - 为什么 Arduino Micro(USB 设备)的供应商 ID 和产品 ID 在 Linux 和 Windows 中不同?

python - 对齐子列表中的数字

Javascript Number.toString(基数) 行为

更改 const char *str1 = "abc"