QT:QString为十六进制 [英] QT: QString to Hexadecimal

查看:1860
本文介绍了QT:QString为十六进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个非常基本的问题,但我是Qt的新手,我不知道这样做。我正在尝试将QString值(如FF)转换为十六进制。我想获得0xFF。我正在寻找类似的东西



来源 QString str =20FF;

目标结果 int hex = 0x20FF;



你能帮帮我吗?谢谢。

I know this is a very basic question but I'm newbie in Qt and I don't know to do it. I'm trying to convert a QString value (like "FF") to hexadecimal. I would like to obtain 0xFF. I am looking something like that

Source QString str= "20FF";
Target Result int hex= 0x20FF;

Could you help me? thanks.

推荐答案

实际上没有'转换为十六进制'。

str 8447 数字的十六进制表示。

0x20FF 只是文字 [ ^ ]您可以使用以便在源代码中指定数字。



[update]

为了比较代表的数字字符串 str 具有实际的 int 值,您首先要转换 str 为整数,使用 16 作为基数。请参阅int QString :: toInt(bool * ok = 0,int base = 10)const [ ^ ]

[/ update]
There is NO 'convert to Hexadecimal', actually.
str is the hexadecimal representation of the 8447 number.
0x20FF is just the literal[^] you could use in order to specify the number in the source code.

[update]
In order to compare the number represented by the string str with an actual int value, you have first to convert str to integer, using 16 as base. See "int QString::toInt(bool * ok = 0, int base = 10) const"[^]
[/update]


这篇关于QT:QString为十六进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆