当前位置:网站首页>QT QString踩坑
QT QString踩坑
2022-04-22 21:02:00 【rainbow_lucky0106】
编码
在main函数中设置 QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QString 转 char*
一:
QByteArray byte_data = str.toUtf8();
char *ch = byte_data.data();
二:
QByteArray byte_data = str.toLocal8Bit();
char *ch = byte_data.data();
三:
std::string str1 = str.toStdString();
const char* ch = str1.c_str();
四:
显式地使用宽字符(wchar_t)或UTF-8才是好方法。
QString str0(QString::fromStdWString(L"数学分析"));
QString str1(QString::fromUtf8(u8"高等代数")); // C++11
五:
QString s1 = "汉语";
QString s2("漢語");
QString s3 = tr("中文")
QString s4 = QStringLiteral("中文");
QString s5 = QString::fromWCharArray(L"中文");
QString s6 = u8"中文";//C++11
QString s7 = tr(u8"中文")
六:
增加VS编译参数:将源码字符集和执行文件字符集指定为UTF-8


七:
#pragma execution_character_set("utf-8")
八:
pro文件中加入
win32:msvc{
QMAKE_CXXFLAGS += /source-charset:utf-8 /execution-charset:utf-8
}
版权声明
本文为[rainbow_lucky0106]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_21980099/article/details/124338829
边栏推荐
- What is a SAML assertion?
- .103Navigator
- Four things we cannot do in media operation
- 【数据库学习01】
- Selenium_Webdriver视频自动化脚本分享
- [radar] point target simulation of simulated synthetic aperture radar (SAR)
- DSPACE simulates simple accident scene
- Evaluaion mark in natural language processing field//updating
- Introduction to unityshader - sketch effect rendering
- Use of dSPACE simulation platform
猜你喜欢

Jingdong new product Intelligence Bureau spoilers oppo K10 series or linkage Guoman IP surprise?

Some understanding of sw-msa in swing-t

对Swin-T中SW-MSA的一些理解

Win10安装Neo4j

2、 Linear regression

jmeter资料及软件

.103Navigator

Semi synchronous replication of MySQL master-slave replication

基于SEIR模型的传染病预测软件开发

博途PLC用户自定义数据类型
随机推荐
The traffic not included in the Internet era is all included in the industrial Internet era
面试官宁愿要刚刚毕业工作1年的我小弟,也不要工作5年的我,年薪25w
机器视觉需要掌握的知识
大量mapper IO优化(使用多线程异步+CountDownLatch)
Is it safe for futures to open an account directly online?
工控安全解决方案
String. Join() and stringutils Join () gracefully solves the splicing of arrays or collections
Ordinary functions as friends (using examples to solve friend functions)
华中师范大学少年儿童组织与思想意识教育考研上岸前辈备考经验
Beyond compare enforces the use of binary transfer to ensure that the files are the same
buuctf-[Flask]SSTI
Question bank and simulation examination of work permit for safety management personnel of hazardous chemical business units in 2022
DSPACE simulates simple accident scene
一、机器学习概念
基于PAOGD_HW1的弹出的小球-简单建模、插值动画
软件测试知识点 | Jmeter实现接口关联小结
MySQL高可用架构设计分析
MySQL advanced stored procedure storage function -- Introduction to stored procedure, basic syntax of stored procedure, variables (system variables, user-defined variables, local variables), if, param
Win10安装Neo4j
基于OpenGL的贪吃蛇游戏设计与实现