开发者

Qt linguist CODECFORTR option in Visual Studio

I am developing Qt application using Visual Studio and Qt Visual Studio Add-in. I am using non-Latin1 characters in my source code, so I need to specify CODECFORTR in .pro file for QtLinguist to display it correctly. But VS add-in doesn't create .pro file, it provided only "lupdate all files" and "lrelease all file" options in project context menu. Is there any way to pass COD开发者_运维问答ECFORTR option to lupdate tool using VS add-in?


Try this:

#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();
}

You may need to change UTF-8 with encoding that u are using


Solved in Qt VS add-in v1.1.9. Added options for lupdate and lrelease tools in Qt project settings dialog.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜