unsinged char 转QString
时间: 2023-05-20 20:05:55 浏览: 92
QString含汉字时,完美转char*和unsigned char*
可以使用QString::fromUtf8()函数将unsigned char数组转换为QString。例如:
unsigned char data[] = {0xE4, 0xBD, 0xA0, 0xE5, 0xA5, 0xBD}; // "你好"的UTF-8编码
QString str = QString::fromUtf8(reinterpret_cast<const char*>(data), sizeof(data));
// str的值为"你好"
阅读全文