• 8979阅读
  • 2回复

[提问]pyqt怎么显示中文? [复制链接]

上一主题 下一主题
离线halida
 

只看楼主 倒序阅读 楼主  发表于: 2009-11-25
— 本帖被 XChinux 从 Qt基础编程 移动到本区(2013-04-01) —
我的源代码采用utf-8,直接传递UTF-8中文字符,但是出来的是乱码。。
我看了pyqt那本书,胡搞瞎搞出来一个ts,转了qm,QTranslator出来了,但是界面上还是显示中文,
我在网上找了一下,没有相关的资料,请问有谁知道怎么办的?最好是最简单的处理方法?
离线dbzhang800

只看该作者 1楼 发表于: 2009-11-25
学pyqt还是要好好看看PyQt4的manual
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html

Initializing a String

One way to initialize a QString is simply to pass a const char * to its constructor. For example, the following code creates a QString of size 5 containing the data "Hello":

     QString str = "Hello";

QString converts the const char * data into Unicode using the fromAscii() function. By default, fromAscii() treats character above 128 as Latin-1 characters, but this can be changed by calling QTextCodec.setCodecForCStrings().
离线halida

只看该作者 2楼 发表于: 2009-11-26
非常感谢!
我又被RTFM一次了。
快速回复
限100 字节
 
上一个 下一个