gpt4 book ai didi

Qt - 如何将数字转换为 QChar

转载 作者:行者123 更新时间:2023-12-02 07:42:59 30 4
gpt4 key购买 nike

我有一个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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com