- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要从 QChar
获取 ASCII 代码。
在 Qt 5.2 中,QChar::ToAscii
已被删除。
这是我的代码。如何获取 ASCII 码?
QString data;
int key;
key = data.at(i);
最佳答案
用途:
char QChar::toLatin1() const
来自文档:
Returns the Latin-1 character equivalent to the QChar, or 0. This is mainly useful for non-internationalized software.
从Qt5.0版本开始
char QChar::toAscii() const
This function is deprecated. Returns the Latin-1 character value of the QChar, or 0 if the character is not representable.
示例
QString test("test");
QChar c = test.at(0);
int v_latin = c.toLatin1();
int v_ascii = c.toAscii();
qDebug() << v_latin << " " << v_ascii;
输出:
116 116
关于Qt:从 QChar 获取 ASCII 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20841929/
我阅读了文档,上面写着 QChar::isNumber()那个 Returns true if the character is a number (Number_* categories, not
我有一个qulonglong变量,我需要把它转换成QChar。 例如,从数字 65 我应该得到 'A'。 或者,如果有一种解决方案可以将其直接转换为 QString 也很好。 最佳答案 您需要的是 Q
我想将 QString 转换成文件名。因为我希望文件名看起来干净,所以我想用下划线替换所有非字母和非数字。以下代码应该可以做到这一点。 #include #include QString make
我需要将 QChar 转换为 wchar_t 我试过以下方法: #include #include #include using namespace std; int main(int argc
如何优雅的获取digits值? QChar qc('4'); int val=-1; if(qc.isDigit()){ val = qc.toLatin1() - '0'; } 看起来不太好。
在 C++ 中,有一种方法可以将 char 转换为 int 并返回 ascii 值。有没有一种方法可以对 qchar 执行相同的操作?由于 unicode 支持如此多的字符,并且其中一些实际上看起来很
#include #include int main(int argc, char *argv[]) { QCoreApplication a (argc, argv); unsi
我正在构建一个 Qt Gui 应用程序来监视来自串行端口的数据。我正在使用 qextserialport 库。这是我遇到的问题。 void MainWindow::onDataAvailable()
我正在研究解析器。我想逐个字符地解析文本文件。 bool parse(QString fileName, QString fieldTerminator,
我需要将 QChar 传递给需要 wchar_t 的函数: void myFunc(wchar_t wch); 尝试只传递 QChar 失败并出现错误: error: C2664: 'myFunc'
我需要从 QChar 获取 ASCII 代码。 在 Qt 5.2 中,QChar::ToAscii 已被删除。 这是我的代码。如何获取 ASCII 码? QString data; int key;
我想制作加密(稍后解密)用户输入的字符串的程序。这是加密的开始: QString getData = ui->text->toPlainText(); //Data to process std::s
在 Java 中,我能够使用 Unicode.blockOf(Character) 确定特定字符是否为日文汉字。我正在尝试为 QChar 做同样的事情,但找不到相关的功能来做到这一点。我想知道我是否只
我有一个应用程序应该处理各种字符,并在某些时候显示有关它们的信息。我在 QChar、QString 等中使用 Qt 及其固有的 Unicode 支持。 现在我需要 QChar 的代码点以便在 http
我正在尝试为 Code page 437 编写编解码器.我的计划是只传递 ASCII 字符并将剩余的 128 个字符映射到一个表中,使用 utf-16 值作为键。 对于某些组合字符(带点的字母、波浪号
可以告诉我为什么下面的代码会导致这个错误: call of overloaded 'QChar(const char[2])' is ambiguous 和代码: void func(QChar a
我正在研究 qt - 在《C++ GUI Programming With Qt 4》一书中,我试图让所有代码都能正常工作。我在将自定义表格小部件中的内容选择转换为纯文本时遇到问题。 书中现有代码:
我是一名优秀的程序员,十分优秀!