当前位置:网站首页>int与string、int与QString互转
int与string、int与QString互转
2022-07-02 06:34:00 【懵懂的梦花火】
1 int转string
1.1 流的 << 运算符
// 流的 << 运算符
int a = 10;
stringstream ss;
ss << a;
string str = ss.str();
1.2 c++11 std::to_string
int a = 10;
std::string s = std::to_string(a);
2 string 转 int
2.1 std::atoi
string _str = pSaveConfigElement->FirstChildElement("SaveVideoWidth")->GetText();
int mVideoWidth = std::atoi(_str);
3 int转QString
3.1.直接调用QString::number()
int number = 10;
QString str = QString::number(number );
4 QString 转 int
QString str = “10”;
int number = str.toInt();
5 QString转string
QString str = “10”;
string stdStr= str.toStdString();
6 string转QString
std::string _stdStr = "sfd";
QString _qStr(_stdStr.c_str());
边栏推荐
- Number structure (C language -- code with comments) -- Chapter 2, linear table (updated version)
- Operation and application of stack and queue
- Solutions to Chinese garbled code in CMD window
- Supplier selection and prequalification of Oracle project management system
- Microservice practice | fuse hytrix initial experience
- 定时线程池实现请求合并
- Navicat 远程连接Mysql报错1045 - Access denied for user ‘root‘@‘222.173.220.236‘ (using password: YES)
- Methods of classfile
- From concept to method, the statistical learning method -- Chapter 3, k-nearest neighbor method
- 企业级SaaS CRM实现
猜你喜欢

Timed thread pool implements request merging

Solutions to Chinese garbled code in CMD window

How to use pyqt5 to make a sensitive word detection tool

一篇详解带你再次重现《统计学习方法》——第二章、感知机模型

Chrome浏览器插件-Fatkun安装和介绍

Taking the upgrade of ByteDance internal data catalog architecture as an example, talk about the performance optimization of business system

DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!

数构(C语言)——第四章、矩阵的压缩存储(下)

web安全与防御

互联网API接口幂等设计
随机推荐
JVM instruction mnemonic
"Interview high frequency question" is 1.5/5 difficult, and the classic "prefix and + dichotomy" application question
分享一篇博客(水一篇博客)
[go practical basis] gin efficient artifact, how to bind parameters to structures
c语言编程题
西瓜书--第五章.神经网络
MySQL multi column in operation
Idea view bytecode configuration
Hystrix implements request consolidation
Amq6126 problem solving ideas
In depth analysis of how the JVM executes Hello World
Chrome video download Plug-in – video downloader for Chrome
Enterprise level SaaS CRM implementation
微服务实战|Eureka注册中心及集群搭建
Flink - use the streaming batch API to count the number of words
[go practical basis] how to install and use gin
Micro service practice | introduction and practice of zuul, a micro service gateway
Number structure (C language) -- Chapter 4, compressed storage of matrices (Part 2)
hystrix 实现请求合并
[go practical basis] how to customize and use a middleware in gin