May 23, 2008
Qt and Windows CEInternationalizing Applications
Notice that the languages in Figure 3 are also different. Figure 3(a) is Norwegian, while 3(b) is German (Swiss).
To internationalize applications in Qt:
Step 4 is usually done by a translator (like QT Linguist), while the other steps are done by you.
[Click image to view at full size]
Figure 3: (a) Image Viewer running in Windows Mobile 6.0 with default native style; (b) Image Viewer running in Windows Mobile 6.0 with custom style sheet enabled.
To switch the language you simply call the QCoreApplication::installTranslator() function. When called during the construction of an application, nothing else is needed for the app to run in the selected language. However, to change the language at runtime, you need to reimplement changeEvent() of the PreviewWindow class to handle LanguageChange:
You call ui.retranslateUi(this) to translate all the user-visible strings that entered when creating the GUI in Qt Designer. However, you also need to update the widgets that have user-visible strings updated by code. That is why I call setTitle() and setText() for the imageName and imageDimension. Notice how the strings are wrapped inside a tr() function. With this reimplementation of changeEvent(), the application supports changing the language at runtime.
|
|
||||||||||||||||||||||||||||||
|
|
|
|