Qt中使用汉字字符与 “error C2001: newline in constant”问题的解决
来源:互联网 发布:淘宝开网店要求 编辑:程序博客网 时间:2024/04/30 04:37
问题描述:我的程序中希望使用下面的代码,将输入框的提示语改为“请输入您的密码”。但是程序出现错误,无法识别汉字字符。
QLineEdit *passwordEdit;passwordEdit->setPlaceholderText("请输入您的密码");
解决方法:使用QString::fromLocal8Bit()方法将汉字字符转码,程序就可以正常识别汉字型QString。将上面的代码修改如下:
QString str; str=str.fromLocal8Bit("请输入您的密码"); passwordEdit->setPlaceholderText(str);
又一个问题:程序报错 “error C2001: newline in constant”
问题分析:代码文件login.cpp的编码方式不对,要将login.cpp文件的编码方式修改为utf-8型的就可以解决这个问题。我使用的修改文件的编码方式的方法是,用记事本软件打开cpp文件,在“另存为”窗口中可以选择文件的编码形式:
保存文件为utf-8型后,重新载入文件和编译程序。错误消失,汉字可以正常显示。
阅读全文
0 0
- Qt中使用汉字字符与 “error C2001: newline in constant”问题的解决
- error C2001: newline in constant
- Qt笔记-MSVC报newline in constant(即奇数个中文汉字的问题)
- 关于QT中奇数个汉字出现newline in constant的错误
- newline in constant error
- unity3d newline in constant error
- unity3d newline in constant error
- Qt vs2010 中文 newline in constant
- unity3d C# Newline in constant
- qt error: C2001: 常量中有换行符
- qt error: C2001: 常量中有换行符
- VC中使用wxWidgets 出现的编译错误 error C2059: syntax error : 'constant' 解决
- VS中使用CXTPDockingPane出现的编译错误 error C2059: syntax error : 'constant' 解决
- Error: missing newline in
- 中文报错newline in constant
- QT中汉字乱码解决方案,解决汉字乱码问题
- 关于qt5中“error c2001: 常量中有换行符”以及个别中文字乱码问题的解决办法
- unity3d开发中遇到的问题:new line in constant
- Python语言学习笔记
- 欢迎使用CSDN-markdown编辑器
- 归并排序
- 如何fintune torch 中某些层的参数
- 自学网络结构(一):Neural Architecture Search With Reinforcement Learning
- Qt中使用汉字字符与 “error C2001: newline in constant”问题的解决
- 关于WPS里面怎么把方框涂黑或者打勾
- 11.13课堂笔记、作业以及学习心得
- 作业编程题111页 用类描述计算机中CPU的速度和硬盘容量
- Spring之组件扫描
- 线索二叉树
- 单点登录原理之简单实现
- 类型转换 C++
- scala中的隐式类型转换