当前位置:网站首页>QT qstring stepping pit
QT qstring stepping pit
2022-04-22 21:07:00 【rainbow_ lucky0106】
code
stay main Function QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QString turn char*
One :
QByteArray byte_data = str.toUtf8();
char *ch = byte_data.data();
Two :
QByteArray byte_data = str.toLocal8Bit();
char *ch = byte_data.data();
3、 ... and :
std::string str1 = str.toStdString();
const char* ch = str1.c_str();
Four :
Use wide characters explicitly (wchar_t) or UTF-8 That's a good way .
QString str0(QString::fromStdWString(L" Mathematical analysis "));
QString str1(QString::fromUtf8(u8" Advanced algebra ")); // C++11
5、 ... and :
QString s1 = " chinese ";
QString s2(" Chinese ");
QString s3 = tr(" chinese ")
QString s4 = QStringLiteral(" chinese ");
QString s5 = QString::fromWCharArray(L" chinese ");
QString s6 = u8" chinese ";//C++11
QString s7 = tr(u8" chinese ")
6、 ... and :
increase VS Compile parameters : Specify the source character set and the executable character set as UTF-8


7、 ... and :
#pragma execution_character_set("utf-8")
8、 ... and :
pro Add... To the document
win32:msvc{
QMAKE_CXXFLAGS += /source-charset:utf-8 /execution-charset:utf-8
}
版权声明
本文为[rainbow_ lucky0106]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204222102108758.html
边栏推荐
- [200 opencv routines of youcans] 160 Otsu method of image processing
- LeetCode-238-除自身以外数组的乘积
- 基于PAOGD的角色动画基础设计
- Rong Lianyun joined hands with China Academy of information and communications to start the development of a series of standards for office instant messaging software
- 互联网时代没有囊括进来的流量,在产业互联网时代全部都被囊括进来
- .bashrc .bash_profile .bash_logout .bash_history
- 农村没网络怎样安监控,家里没有wifi安哪种监控器
- Implementation of simple FreeRTOS task blocking delay based on gd32f1x0 manual programming
- Semi synchronous replication of MySQL master-slave replication
- Introduction to unityshader - sketch effect rendering
猜你喜欢

【数据库学习01】

Confidence interval and interval estimation

容联云携手中国信通院,开启办公即时通信软件系列标准研制

Massive mapper IO optimization (using multithreaded asynchrony + countdownlatch)

Who is important about products and services? Changan Ford tells you "all"

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

Leetcode学习计划之动态规划入门day1,2(共4题)

机器视觉需要掌握的知识

Botu PLC user defined data type

LeetCode HOT 100(买卖股票的最佳时机)
随机推荐
L1-046 整除光棍
对Swin-T中SW-MSA的一些理解
[server data recovery] a data recovery case in which multiple hard disks are disconnected and the server crashes due to water ingress in the server
2022 G3 boiler water treatment national question bank and online simulation examination
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
HDLBits(十 一)学习笔记——有限状态机(FSM onehot - Fsm serialdp)
基于GD32F1x0手动编程实现简易freertos之任务阻塞延时
东吴证券X袋鼠云:数据轻松可取、毫秒级反应能力,东吴证券做对了什么?
自媒体运营中千万不能做的四件事情
OpenVX 的 立即模式(immediate mode)和图模式(graph mode)和示例讲解
Basic use and principle of Minio
Win10安装Neo4j
Massive mapper IO optimization (using multithreaded asynchrony + countdownlatch)
一、机器学习概念
农村没网络怎样安监控,家里没有wifi安哪种监控器
nodejs笔记3
基于PAOGD的角色动画基础设计
重返天梯-L2-020 功夫传人 (25 分)(bfs or dfs)
(1) UART subsystem learning plan
[NOIP2012]借教室