QT QString转char*,char*转QString;简单明了,看代码。
//原始QString
QString qs = QString::fromLocal8Bit("我的");
std::string strQs = qs.toStdString();
int qs_size = qs.length();//长度为3
int strQs_size = strQs.length();//长度8
//得到转换后的char*
char* p = new char[strQs_size];
memcpy(p, qs.toStdString().c_str(), strQs_size);
//再得到QString
std::string strQs1(p, strQs_size);
QString qs1 = QString::fromStdString(strQs1);
QT QString转char*,char*转QString;简单明了,看代码。的更多相关文章
- 例题:计算运费。c#语言基础,比较简单。看代码输入格式和方法。同样方法可以做一个 出租车打车的程序
while (true) { Console.WriteLine("请输入行李重量"); double k = Convert.ToDouble(Console .ReadLine ...
- 【转载】Qt中的QString,QByteArray,Qchar, char*
先要说的是QString. 之所以把QString单独拿出来,是因为string是很常用的一个数据结构,甚至在很多语言中,比如JavaScript,都是把string作为一种同int等 ...
- qt QString 与 int,char的转换
每次QString转换int或者char的时候都要查资料,记录一下,方便下次查看. 参考: http://blog.csdn.net/ei__nino/article/details/7297791 ...
- Qt中的对象类型转换(Qstring 转换char*有三种方法)
char * 与 const char *的转换 char *ch1="hello11"; const char *ch2="hello22"; ch2 = c ...
- 在windows下的QT编程中的char*,wchar_t*与QString之间的转换(利用reinterpret_cast和_stprintf函数,fromWCharArray从字符数组里读取数据)
http://blog.csdn.net/yangxiao_0203/article/details/7422660 转自http://hi.baidu.com/zj41342626/blog/ite ...
- QString, string, int, char* 之间相互转换
这三种数据类型在实际运用中经常需要互相转换,那么这里小结下它们之间的转换方法: - Qstring & string Qt中封装的类十分强大,其成员函数数量之多比STD有过之而无不及,许多程序 ...
- QString, Std::string, char *相互转换
Qt 库中对字符串类型进行了封装,QString 类提供了所有字符串操作方法,给开发带来了便利. 由于第三方库的类型基本上都是标准的类型,即使用std::string或char *来表示字符 (串) ...
- 用Qt写软件系列三:一个简单的系统工具(上)
导言 继上篇<用Qt写软件系列二:QIECookieViewer>之后,有一段时间没有更新博客了.这次要写的是一个简单的系统工具,需求来自一个内部项目.功能其实很简单,就是查看当前当前系统 ...
- 转:char*, char[] ,CString, string的转换
转:char*, char[] ,CString, string的转换 (一) 概述 string和CString均是字符串模板类,string为标准模板类(STL)定义的字符串类,已经纳入C++标准 ...
随机推荐
- (转)Python:self
原文:http://www.douban.com/group/topic/19376685/ 这是对前面一个php程序员问python方法为什么要手写一个self的回答,当时那个帖非常的热闹,但是下面 ...
- Bzoj 1046: [HAOI2007]上升序列 二分,递推
1046: [HAOI2007]上升序列 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 3671 Solved: 1255[Submit][Stat ...
- UIWebview 禁止某个方向滚动
Enable Horizontal scrolling and disable Vertical scrolling: myWebView.scrollView.delegate = self; [m ...
- 【转】【opencv】仿射变换
仿射变换 目标 在这个教程中你将学习到如何: 使用OpenCV函数 warpAffine 来实现一些简单的重映射. 使用OpenCV函数 getRotationMatrix2D 来获得一个 旋转矩阵 ...
- weblogic开发模式与生产模式介绍
weblogic开发模式与生产模式介绍 开发模式:该模式启用自动部署 生产模式:该模式关闭自动部署 weblogic server 三种部署方法:自动部署.控制台部署.命令部署 自动部署:当其处于启用 ...
- [C#] 常用工具类——加密解密类
using System; using System.Configuration; using System.Collections.Generic; using System.Text; using ...
- 【转】maven 项目出现 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
http://blessht.iteye.com/blog/1104450 http://www.cnblogs.com/zhouyalei/archive/2011/11/30/2268606.ht ...
- Android 获取WIFI MAC地址的方法
1. 经常用法,调用Android的API:WifiManager <uses-permission android:name="android.permission.ACCESS_W ...
- 用tsung测试openfire 服务器性能
最近公司需要做一个有聊天功能的应用,客户讲的是很宏大,用户超多,以前搞过openfire,但没有深入的去了解,就想用它来搞,而且是用 java写的,想扩展也容易些,但在性能上一直担忧,想测试一下它的性 ...
- 恭贺自己itpub和csdn双双获得专家博客称号
这是对一个技术人员行业内很难得的认可,记录下来,加油...一切向钱看,明天会更好.