【1】QString 转换为string

     QString qString("好好学习天天向上");
std::string stdString = qString.toStdString();
QTextCodec* pCode = QTextCodec::codecForName("gb18030");
// 如果code为0,表示在运行的机器上没有装gb18030字符集。不过一般的中文windows系统中都安装了这一字符集
if (NULL != pCode)
{
stdString = pCode->fromUnicode(qString).data();
}

【2】string 转换为QString

     std::string stdString = "好好学习天天向上";
QString strQ = QString::fromLocal8Bit(stdString.c_str());

Good Good Study, Day Day Up.

顺序  选择 循环 总结

QString 与 string转换的更多相关文章

  1. Qt QString与string的转换

    QString --> string QString.toStdString();   string --> QString QString::fromStdString(string);

  2. QString与string的相互转换

    1.QString转换String string s = qstr.toStdString(); 2.String转换QString QString qstr2 = QString::fromStdS ...

  3. QString, Std::string, char *相互转换

    Qt 库中对字符串类型进行了封装,QString 类提供了所有字符串操作方法,给开发带来了便利. 由于第三方库的类型基本上都是标准的类型,即使用std::string或char *来表示字符 (串) ...

  4. QString与string的相互转换【转载】

    文章转载自https://blog.csdn.net/qq_33485434/article/details/80680506 1.QString转换String string s = qstr.to ...

  5. 在C#中将String转换成Enum:

    一:  在C#中将String转换成Enum: object Enum.Parse(System.Type enumType, string value, bool ignoreCase); 所以,我 ...

  6. C# 字符串string类型转换成DateTime类型 或者 string转换成DateTime?(字符串转换成可空日期类型)

    在c#中,string类型转换成DateTime类型是经常用到的,作为基本的知识,这里在此做个小结.一般来说可以使用多种方法进行转换,最常用的就是使用Convert.ToDateTime(string ...

  7. string转换成color转

    string转换成color             string col = "#FF8400";            this.BackColor = System.Draw ...

  8. C# 中怎么将string转换成int型

    int intA = 0;1.intA =int.Parse(str);2.int.TryParse(str, out intA);3.intA = Convert.ToInt32(str);以上都可 ...

  9. JAVA中List转换String,String转换List,Map转换String,String转换Map之间的转换类

    <pre name="code" class="java"></pre><pre name="code" cl ...

随机推荐

  1. js一次控制 多个style样式

    ]; m.style.cssText='color:green;background:cyan;' 控制多个过渡效果 m.style.transition='opacity 1s ease-in,ba ...

  2. 虚拟机VirtualBox与CentOS 7安装

    一.VirtualBox 我们电脑的操作系统一般都是Windows,如果我们要学习Linux,那么可以在我们的电脑上装个虚拟机,然后在这虚拟机上安装Linux.虚拟机可以用VirtualBox 或者 ...

  3. jq优化

    1.使用链式写法 $('div').find('h3').eq(2).html('Hello');采用链式写法时,jQuery自动缓存每一步的结果,因此比非链式写法要快.根据测试,链式写法比(不使用缓 ...

  4. session操作类

    using System;using System.Web; /// <summary> ///session操作类 /// </summary> public class a ...

  5. linux搭建PHP开发环境

    因为PHP是一门易于上手的开发语言,所以现在越来越多的初创公司选择PHP作为前期项目的主要开发语言. 工欲善其事,必先利其器! 现在我们就从最基本的环境搭建开始,PHP环境的搭建是非常简单的: 环境: ...

  6. 报错解决——linux下执行sh出现异常"syntax error: unexpected end of file"

    有时我们在linux下执行一个sh文件,会报错“SYNTAX ERROR:UNEXPECTED END OF FILE”,这个现象主要是工作的系统环境改变造成的. 若最初脚本中是在windows下,使 ...

  7. pycharm 运行py文件一直updating indexing

    1.解决一直索引python目录下的文件 File - Settings - Project: yourprojectname - Project Structure - Right click on ...

  8. 在WCF服务端的web.config中增加如下设置,具体的错误会记录在.svclog文件中

    <system.diagnostics> <sources> <source name="System.ServiceModel" switchVal ...

  9. Linux系统下我的/etc/sysconfig/路径下无iptables文件

    转载于:https://blog.csdn.net/zzm8421/article/details/78083582 虚拟机新装了一个CentOs7,然后做防火墙配置的时候找不到iptables文件, ...

  10. [py]super调用父类的方法---面向对象

    super()用于调用父类方法 http://www.runoob.com/python/python-func-super.html super() 函数是用于调用父类(超类)的一个方法. clas ...