Qt localization

I have some problems with the localization of Qt programs. Everything is fine on my computer, but when I send my program to other users, they cannot see the characters of some languages. In this case, I tested Thai.

Program output in screenshots: My operating system: Windows 7 Ultimate x64 SP1 http://myprintscreen.com/s/1id

Custom cpu OS is the same: Windows 7 Ultimate x64 SP1 http://myprintscreen.com/s/1ie

The user can print Thai in Microsoft Word and Notepad ++, but not in the Qt input fields.

And we found an interesting error ( http://myprintscreen.com/s/1if ): If you copy Thai text from Microsoft Word to QTextEdit, it displays fine. QLineEdit and QPlainTextEdit do not display correctly.

On Windows XP x86 SP3 ( http://myprintscreen.com/s/1ii ) is not displayed in Japanese, but with Thai everything is fine :)

I am trying to use:

QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QString::fromUtf8 tr trUtf8 QTextCodec::codecForName("UTF-8")->toUnicode 

Qt project: http://www74.zippyshare.com/v/39453145/file.html

Help me please. I canโ€™t figure out what to do to make it work.

+4
source share
1 answer

The solution was simple. A problem with fonts on the user's computer. In my case, Qt uses the default MS Shell Dlg 2 font. But on the user's computer, it was "damaged". I added this code:

 QApplication::setFont(QFontDialog::getFont(0, QApplication::font())); 

and continue testing. Some fonts are displayed, and some are not. Different computers have different behaviors.

That's why I decided to add the font I needed to the distribution and install it for QApplication.

+3
source

Source: https://habr.com/ru/post/1484674/


All Articles