Qt 十六进制的简单应用, 十六进制的加法

本文介绍了Qt库中如何进行十六进制与十进制之间的转换,包括将十六进制转为十进制,以及将十进制转为十六进制的方法。此外,还探讨了十六进制的加法操作,并提供了相关的应用示例。

Qt 十六进制的简单应用, 十六进制的加法

1. 十六进制转为十进制

int QString::toInt(bool *ok = Q_NULLPTR, int base = 10) const

Returns the string converted to an int using base base, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails.
If a conversion error occurs, *ok is set to false; otherwise *ok is set to true.
If base is 0, the C language convention is used: If the string begins with “0x”, base 16 is used; if the string begins with “0”, base 8 is used; otherwise, base 10 is used.

bool ok;
QString hex = "100";
int dec = hex.toInt(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值