Sapien2
Sapien2

Reputation: 237

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 CODECFORTR option to lupdate tool using VS add-in?

Upvotes: 2

Views: 1225

Answers (2)

Sapien2
Sapien2

Reputation: 237

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

Upvotes: 0

xenofanes
xenofanes

Reputation: 11

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

Upvotes: 1

Related Questions