QString 转换成 16进制数
时间: 2024-01-12 20:51:16 浏览: 36
可以使用QString的toUtf8()函数将QString转换为QByteArray,然后使用QByteArray的toHex()函数将其转换为16进制字符串。
示例代码:
```cpp
QString str = "Hello, world!";
QByteArray byteArray = str.toUtf8();
QString hexString = byteArray.toHex();
```
这里的hexString即为转换后的16进制字符串。
相关问题
qt qstring 转换成16进制
您好,您可以使用QString的toUtf8()方法将QString对象转换为QByteArray对象,然后使用QByteArray的toHex()方法将其转换为16进制字符串。
示例代码如下:
```cpp
QString str = "Hello, World!";
QByteArray byteArray = str.toUtf8();
QString hexStr = byteArray.toHex();
```
用QT 写一个 16进制的QString 转换为10进制的int
可以使用QString类的toInt()函数将16进制的QString转换为10进制的int,如:QString str = "0xFF"; int i = str.toInt(NULL, 16); // i = 255
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)