QT5中QString与char *的相互转换
以例子说明:
#include <QApplication>
#include <QDebug>
#include <QString>
#include <QByteArray> int main(int argc, char *argv[])
{
QApplication a(argc, argv); char abc[];
memset(abc, , sizeof(abc)); QString str("hello world.");
QByteArray arr;
arr = str.toUtf8(); memcpy(abc, arr.data(), strlen(arr.data())); qDebug() << abc;
QString temp = QString::fromUtf8(abc);//将char*转换为QString qDebug() << temp; return a.exec();
}
结果输出:
hello world.
"hello world."
QT5中QString与char *的相互转换的更多相关文章
- Qt中 QString 转 char*
Qt下面,字符串都用QString,确实给开发者提供了方便,想想VC里面定义的各种变量类型,而且函数参数类型五花八门,经常需要今年新那个类型转换 Qt再使用第三方开源库时,由于库的类型基本上都是标准的 ...
- Qt中QString,int,char,QByteArray之间相互转换
http://blog.csdn.net/ymc0329/article/details/7284514 int 转 QString int m=1; QString b; b=QString::n ...
- QString与char*的相互转换
原地址:http://blog.sina.com.cn/s/blog_5c70dfc80100r0nh.html 一.QString转char* QString str; int num=0; s ...
- Java 中byte 与 char 的相互转换 Java基础 但是很重要
char转化为byte: public static byte[] charToByte(char c) { byte[] b = new byte[2]; b[0] = ...
- Qt中Qstring,char,int,QByteArray之间到转换(转)
11.各种数据类型的相互转换char * 与 const char *的转换char *ch1="hello11";const char *ch2="hello22&qu ...
- Qt中 QString 和int, char等的“相互”转换
转载:http://blog.csdn.net/ei__nino/article/details/7297791 Qt中 int ,float ,double转换为QString 有两种方法 1.使用 ...
- Qt中 QString 和int, char等的“相互”转换,关键是QString.toLocal8Bit().data();
Qt中 int ,float ,double转换为QString 有两种方法 1.使用 QString::number(); 如: long a = 63; QString s = QString:: ...
- Qt中的对象类型转换(Qstring 转换char*有三种方法)
char * 与 const char *的转换 char *ch1="hello11"; const char *ch2="hello22"; ch2 = c ...
- QT中QString 与 int float double 等类型的相互转换
Qt中 int ,float ,double转换为QString 有两种方法 1.使用 QString::number(); 如: long a = 63; QString s = QString:: ...
随机推荐
- Codeforces Round #194 (Div. 2) D. Chips
D. Chips time limit per test:1 second memory limit per test:256 megabytes input:standard input outpu ...
- logfile提示stale错误解决方法
产生该错误的原因解释如下: Explanation: ============ A stale redo log file is one that Oracle believes might be i ...
- 移动网页版Meta 标签
viewport 大部分移动浏览器都接受,比如 Opera Mobile, iPhone, Android, Iris, IE, BlackBerry, Obigo, Firefox 最基本的例子,在 ...
- 容联手机接口封装到ThinkPHP3.2.菜鸟图文教学
今天来说下短信发送技术. 使用的是 容联http://www.yuntongxun.com/ 用法很简单, 具体要知道的参数有 ACCOUNT SID 应用ID AUTH TOKEN 应用toke ...
- JAVA混型和潜在类型机制
一.混型 ①.定义 二.利用JAVA如何实现混型 ①.代理 ②.装饰器模式 ③.动态代理模式 ④.装饰器模式与代理模式的区别 三.潜在类型机制 ①.定义 四.JAVA的潜在类型机制的补偿 ① ...
- listvew加载更多
http://bbs.51cto.com/thread-968277-1.html 又是新的一周的开始,上午自己写了上拉加载更多数据的demo,嘿嘿这里和大家分享. android开发中,list ...
- Delphi通过GetFileVersionInfo和VerQueryValue等API函数取得详细EXE信息
This has been described at About: http://delphi.about.com/cs/adptips2001/a/bltip0701_4.htmBasically, ...
- HDU 4721 Food and Productivity (二分+树状数组)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 题意 :给出n * m的格子,每个格子有两个属性f ...
- curl几个选项
1.--cacert 选项请看https://curl.haxx.se/docs/sslcerts.html 2.CURL库怎样验证服务器证书 [复制链接] 中提到:你是客户端, 你希望的是: 你拿 ...
- 一个月AS2.0总结。
来这家公司一个月了,从最初学习它的木块,到流程,到组件,到改动,到自己做. 感觉好快. 1.AS2.0确实比較3.0差距太大.假设不是公司必须使用2.0,我是真不想使用. 2.代码重用性差.相同的代码 ...