2010-12-20 72 views
2

我正在开发使用Visual Studio和Qt Visual Studio加载项的Qt应用程序。我在源代码中使用非Latin1字符,所以我需要在.pro文件中指定CODECFORTR以便QtLinguist正确显示它。但是VS加载项不会创建.pro文件,它只在项目上下文菜单中提供“lupdate all files”和“lrelease all file”选项。有没有办法将CODECFORTR选项传递给使用VS加载项的lupdate工具?Visual Studio中的Qt语言学家CODECFORTR选项

回答

0

在Qt的VS解决插件V1.1.9。 在Qt项目设置对话框中增加了lupdate和lrelease工具的选项。

1

试试这个:

#include <QApplication> 
#include <QtGui> 
#include <QTextCodec> 

int main(int argc, char *argv[]){ 

    QApplication a(argc, argv); 

    QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); 
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); 
    QTextCodec::setCodecForCStrings (QTextCodec::codecForName("UTF-8")); 
    ... 
    ... 
    return a.exec(); 
} 

您可能需要更改UTF-8编码带,美使用