int QString::toInt(bool *ok = Q_NULLPTR, int base = 10) const
来源:互联网 发布:淘宝创业必备知识 编辑:程序博客网 时间:2024/05/21 17:29
以下为官方文档:
int QString::toInt(bool *ok = Q_NULLPTR,intbase = 10) const
Returns the string converted to anint 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 tofalse; otherwise *ok is set totrue.
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.
The string conversion will always happen in the 'C' locale. For locale dependent conversion useQLocale::toInt()
Example:
QString str = "FF";
bool ok;
int hex = str.toInt(&ok, 16); // hex == 255, ok == true
int dec = str.toInt(&ok, 10); // dec == 0, ok == false
我认为转换之前会进行类型检测,如果无法转换,OK变为0,返回值为0,同时ok一直为0,我们也可以在后续去判断反之为1,转换成功
阅读全文
0 0
- int QString::toInt(bool *ok = Q_NULLPTR, int base = 10) const
- int QString::size () const
- const int &i=10
- const volatile int i = 10
- const volatile int i = 10
- const volatile int i = 10
- const volatile int i = 10
- const volatile int i = 10
- const volatile int i=10
- const int &i=value();
- const int **pp = &p;
- long int strtol(const char *nptr,char **endptr,int base)
- long int strtol(const char *nptr, char **endptr, int base)
- Python标准库:内置函数int(x, base=10)
- int * const *, const int * const *, const int **
- C#中 int int.parse() 和convert.ToInt()的区别
- BOOL ScrollDC(HDC,int,int,CONST RECT *,CONST RECT *,HRGN ,LPRECT);
- const int a = 10; int *p = (int *)&a; *p = 100; a的值到底有没有改变
- gstreamer入门
- django 使用 oracle 数据库的问题
- Map两种迭代方法
- 基类 派生类 算一个数乘积
- [LeetCode] Search in Rotated Sorted Array
- int QString::toInt(bool *ok = Q_NULLPTR, int base = 10) const
- 素数环
- echarts显示图表
- IOS开发要注意数组的赋值问题
- Unicode 和 UTF-8 有何区别?
- linux简介
- 3.4AP_HAL::RCInput and AP_HAL::RCOutput
- PyCharm注册码(破解方法)
- 最长上升子序列