qt50一1`5蓝筹股是什么意思思

Qt4.8.4和creator和mingw安装配置说明总结_非常有用_图文_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
评价文档:
Qt4.8.4和creator和mingw安装配置说明总结_非常有用
Q​t..和​c​r​e​a​t​o​r​和​m​i​n​g​w​安​装​配​置​说​明​总​结​_​非​常​有​用
阅读已结束,如果下载本文需要使用
想免费下载本文?
你可能喜欢当前访客身份:游客 [
当前位置:
Qt更新了最新版本5.0.1,可是对中文显示问题一直没弄清楚。
1.不管源代码(cpp)文件是unicode还是utf8还是ascii格式,只要是中文字符串,都无法正常显示。
2.如果使用国际化,tr(&中文&),也是无法显示,就算添加下面的代码,也还是无法显示。
QTextCodec::setCodecForLocale(QTextCodec::codecForName(&gbk&));
对于1,如果使用下面代码,则可以正常显示
QString::fromLocal8Bit(&中文&)
请熟悉的朋友给予解答,该怎么来使用Qt显示中文?(是在Qt5.0.1版本,VS2010或者Qt creator)。
---------------问题补充---------------
:Qt Creator无法显示中文的问题已经找到答案了:
如果Qt Creator创建的源文件是带BOM的utf8格式,则无法正常显示中文。
必需是不带BOM的utf8格式。
共有21个答案
<span class="a_vote_num" id="a_vote_num_
要搞清楚这个问题,先要弄明白编码。但是编码问题实在太复杂,这里肯定讲不开。
我先找一个例子,比如:&中文& 的 Unicode 码点/UTF8编码/GBK 分别是多少。
先去这个网站,输入 &中文& 查询对应的 Unicode 码点/UTF8编码:
Unicode的码点分别是(十进制):中(20013),文(25991)。
对应的UTF8编码分别(16进制): 中(E4B8AD),文(E69687)。
然后再去下面这个网站,输入 &中文& 查询对应的 GBK 编码:
GBK编码16进制(GBK内码)分别是:中(D6D0),文(CEC4)。
现在已经知道了&中文&的UTF8和GBK编码的具体值。
我们再看看VC2010是怎么处理的。
1. 先看 无 BOM 的 UTF8 编码的代码 (utf8_no_bom.cpp)
// utf8 no bom
// 文件中包含不能在当前代码页(936)中表示的字符
#include &stdio.h&
int main() {
const char* str = &中文&;
for(int i = 0; i & sizeof(str); ++i) {
printf(&0x%x &, str[i]&0xFF);
// Output:
// 0xe4 0xb8 0xad 0xe6
} 输出是:0xe4 0xb8 0xad 0xe6。
感觉好像是对的。
但是,先别急:VC编译时输出了一条警告信息:
utf8_no_bom.cpp : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。
请将该文件保存为 Unicode 格式以防止数据丢失。
潜台词就是,你这个代码有GBK不能表示的字符,请用Unicode方式保存。
VC根本就没把 代码(utf8_no_bom.cpp) 当作UTF8,VC只是把它作为GBK处理罢了。
那为什么又输出了正确的结果呢?
因为 VC 把 (utf8_no_bom.cpp) 当作 GBK,而编译时也要转换为本地编码(也是GBK)。因此,UTF8编码的 &中文&,被VC当作编码GBK编码的 &0xe4 0xb8 0xad 0xe6& 的字符串处理了(肯定不是&中文&含义了)。
VC已经不知道 &0xe4 0xb8 0xad 0xe6& 是对应 &中文& 字面值了。
但是在GBK(实际是无BOM的UTF8)转GBK的过程中,发现了一些UTF8编码的字符并不是GBK能表达的合理方式,因此就出现了那个C4819编译警告。
2. 再看带BOM的UTF8是怎么处理的 (utf8_with_bom.cpp)
// utf8 with bom
#include &stdio.h&
int main() {
const char* str = &中文&;
for(int i = 0; i & sizeof(str); ++i) {
printf(&0x%x &, str[i]&0xFF);
// Output:
// 0xd6 0xd0 0xce 0xc4
编译没有警告,但是输出有问题:0xd6 0xd0 0xce 0xc4。
源文件明明是 UTF8 编码的格式&0xe4 0xb8 0xad 0xe6&, 怎么变成了 &0xd6 0xd0 0xce 0xc4& (这个是GBK编码)?
这就是VC私下干的好事:它自作聪明的将UTF8源代码转换为GBK处理了!
VC为何要做这样蠢事?
原因是为了兼容老的VC版本。 因为以前的VC不能处理UTF8,都是用本地编码处理的。
3. 在看看真的GBK是怎么处理的 (gbk.cpp)
#include &stdio.h&
int main() {
const char* str = &中文&;
for(int i = 0; i & sizeof(str); ++i) {
printf(&0x%x &, str[i]&0xFF);
// Output:
// 0xd6 0xd0 0xce 0xc4
} 没有编译错误,输出也和源代码一致:&0xd6 0xd0 0xce 0xc4&。
因为源文件就是GBK,cl在编译时GBK转化为GBK,没有改变字符串。
只是,现在很多人不想用GBK了(因为只能在中国地区用,不能表示全球字符)。
到这里,可以初步小结一下:
1. VC编辑器和VC编译器是2个概念,VC编辑器支持UTF8并不能表示VC编译器也支持UTF8
2. VC编辑器从2008?开始支持带BOM的UTF8(不带BOM的暂时没戏,因为会本地编码冲突)
3. VC编译器从2010开始也可以支持UTF8了(虽然支持方式很不优雅)
继续前面的测试,
看看VC2010编译器是怎么支持带BOM的UTF8的 (utf8_with_bom_2010.cpp)
// utf8 with bom (VC2010), 下面这句是重点!
#pragma execution_character_set(&utf-8&)
#include &stdio.h&
int main() {
const char* str = &中文&;
for(int i = 0; i & sizeof(str); ++i) {
printf(&0x%x &, str[i]&0xFF);
// Output:
// 0xe4 0xb8 0xad 0xe6
} 没有编译错误,输出也和源代码一致:&0xe4 0xb8 0xad 0xe6&。
UTF8编码,UTF8输出。完美!
回到 Qt5 的中文输出问题。
Qt默认支持 VS2010/MinGW/Gcc 等编译器,而它们现在都已经真正支持UTF8了。
当然,VS2010 对UTF8的支持会入侵代码(#pragma execution_character_set(&utf-8&))。
看看Qt官方论坛别人是怎么说的:
Nothing special need to do, it will works by default.
If the exec-charset of your your compiler is UTF-8.
简单的说,从Qt5开始,源代码就是默认UTF8编码的。
当然,VC2010编辑器对带BOM的UTF8也是认识,只可惜VC2010编译器根本人认识!
在继续看官方论坛的回复:
You can write a simple example like this
#include &QApplication&
#include &QLabel&
#if _MSC_VER &= 1600
#pragma execution_character_set(&utf-8&)
int main(int argc, char *argv[])
QApplication a(argc, argv);
QLabel label(&???&??ń??&);
label.show();
return a.exec();
If other people can reproduce your problem, you can file a bug.
就是我之前贴的代码。只不过我贴的代码增加了Qt4/Qt5和非VC环境的判断。
当然,如果你要是不相信,那我也没什么可说的了...
PS: 此文已经放到我 @chai2010 的博客了(以后有时间再完善):
<span class="a_vote_num" id="a_vote_num_
qt5的中文和英文是一样的用,不需要特殊处理。
看看是不是没有中文字体。
<span class="a_vote_num" id="a_vote_num_
楼主是在pc上还是在嵌入式。前段时间qt5在arm上触摸屏没搞定
<span class="a_vote_num" id="a_vote_num_
Qt5好像只认UTF8了。
对于VC,即使源代码是带BOM的UTF8,编译时好像还是会转换为本地编码。
如果是VC2010,可以用 execution_character_set 选项强制启用UTF8编码:
// Coding: UTF-8
#pragma execution_character_set(&utf-8&)
Qt5的代码不用设置编码。不过为了和Qt4兼容,可以加入以下代码:
#if QT_VERSION & QT_VERSION_CHECK(5,0,0)
#if defined(_MSC_VER) && (_MSC_VER & 1600)
QTextCodec::setCodecForTr(QTextCodec::codecForName(&GB18030-0&));
QTextCodec::setCodecForTr(QTextCodec::codecForName(&UTF-8&));
#endif 当然源代码建议是带BOM的UTF8,并且包含 `#pragma execution_character_set(&utf-8&)` 选项。
<span class="a_vote_num" id="a_vote_num_
引用来自“张某人某人”的答案 qt5的中文和英文是一样的用,不需要特殊处理。
看看是不是没有中文字体。
在windows上使用,肯定是有中文字体啊,
使用下面代码都可以正常显示中文
QString::fromLocal8Bit(&中文&) 而且ui文件自动生成的.h中的中文(用8进制转换了)都可以正常显示。
<span class="a_vote_num" id="a_vote_num_
引用来自“张某人某人”的答案楼主是在pc上还是在嵌入式。前段时间qt5在arm上触摸屏没搞定pc上使用
<span class="a_vote_num" id="a_vote_num_
引用来自“木头r”的答案引用来自“张某人某人”的答案 qt5的中文和英文是一样的用,不需要特殊处理。
看看是不是没有中文字体。
在windows上使用,肯定是有中文字体啊,
使用下面代码都可以正常显示中文
QString::fromLocal8Bit(&中文&) 而且ui文件自动生成的.h中的中文(用8进制转换了)都可以正常显示。
ui生成的UTF8是用C语言的转义字符实现的,VC不会私下做手脚,因此是能显示的。
<span class="a_vote_num" id="a_vote_num_
引用来自“chai2010”的答案 Qt5好像只认UTF8了。
对于VC,即使源代码是带BOM的UTF8,编译时好像还是会转换为本地编码。
如果是VC2010,可以用 execution_character_set 选项强制启用UTF8编码:
// Coding: UTF-8
#pragma execution_character_set(&utf-8&)
Qt5的代码不用设置编码。
不过为了和Qt4兼容,可以加入以下代码:
#if QT_VERSION & QT_VERSION_CHECK(5,0,0)
#if defined(_MSC_VER) && (_MSC_VER & 1600)
QTextCodec::setCodecForTr(QTextCodec::codecForName(&GB18030-0&));
QTextCodec::setCodecForTr(QTextCodec::codecForName(&UTF-8&));
#endif 当然源代码建议是带BOM的UTF8,并且包含 `#pragma execution_character_set(&utf-8&)` 选项。 你的意思是只要源代码文件是带BOM的utf8,就可以正常显示中文?
可是我用Qt creator生成的工程也一样无法显示啊,源代码文件就是带BOM的utf8。
而且Qt5中已经没有setCodecForTr了啊。
<span class="a_vote_num" id="a_vote_num_
带BOM的UTF8只能让VC看着不会出现中文乱码。
但是编译时,好像还是会将源文件转换为本地编码的。
对于VC2010或者更新版本的VC关键是要包含:
#pragma execution_character_set(&utf-8&)
当然,如果没有非英文的字符串,包不包含就没影响了。
完整的例子(Qt5/VC2010):
// Coding: UTF-8(BOM)
#if defined(_MSC_VER) && (_MSC_VER &= 1600)
# pragma execution_character_set(&utf-8&)
#include &QApplication&
#include &QTextCodec&
#include &QLabel&
int main(int argc, char* argv[])
QApplication app(argc, argv);
#if QT_VERSION & QT_VERSION_CHECK(5,0,0)
#if defined(_MSC_VER) && (_MSC_VER & 1600)
QTextCodec::setCodecForTr(QTextCodec::codecForName(&GB18030-0&));
QTextCodec::setCodecForTr(QTextCodec::codecForName(&UTF-8&));
QLabel *label = new QLabel(QObject::tr(&你好!&));
label-&show();
return app.exec();
<span class="a_vote_num" id="a_vote_num_
可以试试下面的代码
void Global::setCodec(char *codeName)
QTextCodec *codecs = QTextCodec::codecForName(codeName);
if (NULL == codecs)
codecs = QTextCodec::codecForLocale();
QTextCodec::setCodecForLocale(codecs);
QTextCodec::setCodecForTr(codecs);
QTextCodec::setCodecForCStrings(codecs);
Global::setCodec(&GB18030&);
更多开发者职位上
有什么技术问题吗?
木头r的其他问题
类似的话题当前访客身份:游客 [
当前位置:
Qt 5.3.1 发布
Qt 5.3.1 发布,此版本作为一个分支版本,并没有添加新特性,但是对系统进行了各种改进,还有大量的 bug 修复。此版本包括了
版本,企业版的完全支持 1.0.0(启动速度提升了 30-40%),更新&
到版本 1.1, 到版本 1.4。主要改进如下:Performance optimizations for Qt Quick Engine’s JIT compiler code generation and important bug fixes, especially on ARM ()QAbstractProxyModel::sibling to now works in the same manner as with Qt4Many small fixes to Qt Quick Controls, for example to TableView, TabView, ComboBox and CalendarQQuickWidget now works properly also with ANGLE ()Qt Quick animations now work also with static builds ()Fix for a regression of QPushButton with QMenu ()Fix for a regression on Mac for passing click event to underlaying widget ()Initial support for Mac OS X 10.10, more improvements will land on upcoming Qt releasesPositioning backend now available also for Windows PhoneAccessibility now works on Android also below API level 18 ()Fix flashing white screen at startup/shutdown on Android ()Support for upcoming Android L ()更多更新内容请看,查看更多已知问题请看,下载请前往。
Qt 的详细介绍:
Qt 的下载地址:
想通过手机客户端(支持 Android、iPhone 和 Windows Phone)访问开源中国:
旧一篇: 1年前
新一篇: 1年前
相关讨论话题
你也许会喜欢
卧槽,没人关注?
你妹的,昨天刚装的5.3.0
3楼:Yu-shi 来自
我能说我刚装5.3.0吗
4楼:Nemesis_E
前天晚上下载安装的5.3.0 ...
5楼:shawumus
怎么这么多刚装530
6楼:二的基本算合格
我比你们装的早,但是也TMD没早装几天~~~
8楼:张金富
更新太快伤不起!
9楼:cr2121
曾经等5.2等了几个月
10楼:zhjx922
能自动更新吗。。每次都全下?
11楼:一如当初
引用来自“zhjx922”的评论能自动更新吗。。每次都全下?说些外行话。
12楼:zhjx922
引用来自“zhjx922”的评论能自动更新吗。。每次都全下?引用来自“一如当初”的评论说些外行话。本来就是外行。。
13楼:罪恶的花生
这种古董还有人用?
14楼:唯一
ubuntu14.04为什么中文是小方块呀,怎么破
15楼:JosonWang
引用来自“罪恶的花生”的评论这种古董还有人用?搞笑,你是在说MFC吗
16楼:饼干的荣耀
引用来自“zhjx922”的评论能自动更新吗。。每次都全下?引用来自“一如当初”的评论说些外行话。引用来自“zhjx922”的评论本来就是外行。。msys2
17楼:dosmlp
引用来自“罪恶的花生”的评论这种古董还有人用?逗比青年
18楼:魅蓝月夜 来自
5.3.0串口模块不知道是不是有bug,延迟厉害,退回5.2就没问题了,郁闷
19楼:DF_XYZ
引用来自“唯一”的评论ubuntu14.04为什么中文是小方块呀,怎么破只能自己编译
20楼:songqt
引用来自“罪恶的花生”的评论这种古董还有人用?引用来自“JosonWang”的评论搞笑,你是在说MFC吗MFC怎么了,我就在用MFC
与内容无关的评论将被删除,严重者禁用帐号
本周热点资讯
本站最新资讯4186人阅读
Download Qt, the cross-platform application framework
Select the file according to your operating system from the list below to get the latest Qt 5.1 for your computer. The binary packages include Qt 5.1.1 libraries
and Qt Creator 2.8.1
Qt is available under GPL v3, LGPL v2 and a&. Learn more about licenses&.
Develop with a Qt Enterprise Commercial License
The Qt Enterprise commercial license offers varied licensing terms and includes additional functionality, support and product updates.
You can get split source packages from&. The source code is also available
as a single&(280 MB) ()
file for Windows users or as&&(226
MB) () file for Linux/Mac
users. All the installers are available also&. Or visit the repository at&
The MinGW binary package includes a 32 bit MinGW-builds (gcc 4.8.0, dwarf exception
handing, posix threading) toolchain. Sources are available from the&or from&.
The Windows offline installers are by default ANGLE based. If you want to know
more about the differences between ANGLE and OpenGL packages on Windows, please visit&.
Looking for Qt 5.2.0 Beta 1? Please visit&.
Select the file according to your operating system from the list below to get the latest Qt 4.8 for your computer
&()&and&&()
The source code is available as a&&(269
MB) () or a&&(230
MB) (). Or visit the repository
Older versions
Qt 5.0, Qt 4.7 and all older versions of Qt are available&.
Be sure to check if Qt is supported on your platform and read the installation notes that are located in the&.
Qt Creator 2.8.1 is included in the Qt 5.1.1 binary packages. If you need a standalone installer, please select the file according to your operating
system from the list below to get the latest Qt Creator for your computer
The source code is available as a&&(29
MB) () or a&&(23
MB) (). Or visit the repository at&.
Qt Creator is available under GPL v3, LGPL v2 and a&. Learn more about licenses&.
Other downloads
& (supports versions
and 2010, does not work with the Express edition)
& (supports versions
and 2012, does not work with the Express edition)
Please check the individual downloads for licensing information.
The Nokia Qt SDK for Symbian and MeeGo can be found from Nokia Developer site
Qt is available under GPL v3, LGPL v2 and a&. Learn more about licenses&.
Developing with Qt professionally?
Commercial license of Qt offers more flexible licensing terms compared to the LGPL, additional modules, and includes support ensuring that someone is there for you if you need help.&.
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:589229次
积分:9206
积分:9206
排名:第863名
原创:250篇
转载:302篇
译文:17篇
评论:127条
(12)(21)(16)(32)(16)(7)(2)(4)(9)(15)(12)(10)(21)(34)(37)(24)(17)(29)(41)(27)(4)(5)(3)(1)(1)(1)(5)(8)(1)(1)(9)(5)(12)(14)(5)(21)(14)(15)(8)(11)(6)(4)(14)(1)(5)(11)

我要回帖

更多关于 p2p是什么意思 的文章

 

随机推荐