unicode中的QApplication [英] QApplication in unicode

查看:152
本文介绍了unicode中的QApplication的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

QApplication的构造函数接受一个(int argc,char ** argv)来处理任何Qt特定的命令行参数。

QApplication's constructor takes an (int argc, char**argv) to handle any Qt specific commandline arguments.

如果我的应用程序在unicode中怎么办?我有一个wchar_t ** argv?

What if my app is in unicode? And I have a wchar_t** argv?

似乎有点愚蠢,创建一个char *副本的所有命令行参数传递给一个本身是unicode的库。

It seems a bit silly to create a char* copy of all the commandline args to pass to a library that is itself unicode.

推荐答案

是的,会的。如果不是此注释

Yes, it would be. If it wasn't for this note:

警告:在Unix上,此列表是从argc和argv参数
构建的
,传递给
main()函数中的构造函数。
argv中的字符串数据使用
解释QString :: fromLocal8Bit();因此它是
不能通过,例如
在以拉丁语1语言环境运行的
系统上的日语命令行参数。
大多数现代Unix系统没有
这个限制,因为它们是
基于Unicode的。

Warning: On Unix, this list is built from the argc and argv parameters passed to the constructor in the main() function. The string-data in argv is interpreted using QString::fromLocal8Bit(); hence it is not possible to pass, for example, Japanese command line arguments on a system that runs in a Latin1 locale. Most modern Unix systems do not have this limitation, as they are Unicode-based.

在基于NT的Windows上,这个限制
也不适用。在Windows上,
参数()不是从argv / argc的
内容构建的,因为内容
不支持Unicode。相反,
arguments()是从GetCommandLine()的
返回值构造的。作为
的结果,由
arguments()。at(0)给出的字符串可能不是Windows上的
程序名,取决于
应用程序是如何启动的。

On NT-based Windows, this limitation does not apply either. On Windows, the arguments() are not built from the contents of argv/argc, as the content does not support Unicode. Instead, the arguments() are constructed from the return value of GetCommandLine(). As a result of this, the string given by arguments().at(0) might not be the program name on Windows, depending on how the application was started.

诚然,我没有收到

这篇关于unicode中的QApplication的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆