365key.com
发现·保存·分享@天天网摘

Q版365key  设为首页 加为收藏 帮助

 首页  网址  添加  我的网摘  我的订阅  最新网摘  收录榜  点击榜  同好  配置  工具箱  标签  兴趣小组 
  IT168 |  华军下载 |  猫扑 |  VeryCD |  CSDN技术 |  DoNews |  9Flash |  中金 |  游侠 |  股票天下 |  游戏公会 |  电子工程 |  白银时代 |  和365Key合作

wendy924的网摘列表 RSS格式输出  365Key邮件订阅,每天可以定期收到邮件通知  使用 POTU 订阅
搜索词: 时间:
分类:     排序:
 
刷新列表 共1页、2项网摘
电影中的经典穿帮镜头点击:32
 分类:QT 时间:2005-4-26 21:20:39 wendy924收录 复制到我的网摘
电影中的经典穿帮镜头
http://blog.itpub.net/post/670/27171
QT编程直接使用中文(转贴) 点击:22
 分类:QT 时间:2005-4-25 10:28:09 wendy924收录 复制到我的网摘
在QT中可以直接QTextCodec来转换字符串的编码,这为在QT下开发中文软件带来了便利条件,不过这种方法不符合国际化/本地化的标准:
char *string = "你好,世界!";
//QCString string= "你好,世界!";
QTextCodec *codec = QTextCodec::codecByName("GBK");
QString strText = codec->toUnicode(string);
QLabel *label = new QLabel(strText);

最直接的方法是把整个应用程序的编码设置为GBK编码,然后在字符串这前加tr:
qApp->setDefaultCodec( QTextCodec::codecForName("GBK") );
...
QLabel *label = new QLabel(tr("你好,世界!"));
例:
#include
#include

int main( int argc, char *argv[] )
{
QApplication app( argc, argv );
app.setDefaultCodec( QTextCodec::codecForName("GBK") );
QLabel label(tr("你好,世界!"), NULL);
app.setMainWidget(&label);
label.show();
return app.exec();
}


如果使QT根据Locale的环境变量取得字符集,可以使用如下命令:
QString::fromLocal8Bit("你好,世界!");
例:
#include
#include

int main( int argc, char *argv[] )
{
QApplication app( argc, argv );
QLabel label(QString::fromLocal8Bit("你好,世界!"), NULL);
app.setMainWidget(&label);
label.show();
return app.exec();
}

以上方法开发不符合国际化编程的习惯,如果编写支持多种编码的软件,一定要采用国际化方法。
http://www.wendy924.ik8.com
页码: [1 共1页、2项网摘

使用帮助 |  如何保存网摘 |  给365Key提建议 |  媒体报道 |  站长推广须知
Copyright (C) 2004 365Key.com--天天网摘 All Rights Reserved