Recently, in order to implement the multi-language interface switching using the software designed by QT, some materials have been collected and tested, and some problems have been found on my platform. To sum up, for future use.
Bytes --------------------------------------------------------------------------------------------------------------------
I recently saw a blog post on installing a translator on the Internet, which roughly means that the translator must be installed before the interface is displayed. Otherwise, the translated interface cannot be displayed.
Reference part of the Code: Signature :-----------------------------------------------------------------------------------------------------The following order is correct.
Qtranslator Translator (0 );
Translator. Load ("French. QM ",".");
App. installtranslator (& translator );
Mywidget m;
App. setmainwidget (& M );
M. Show ();
The following sequence is incorrect. The translator is installed only after the interface is displayed.
Mywidget m;
App. setmainwidget (& M );
M. Show ();
Qtranslator Translator (0 );
Translator. ("myexec_zh.qm", "."); // match the name of the Qm file.
App. installtranslator (& translator );
The error is that the translator is installed only after the interface is displayed, and the translator cannot be translated. You must install the translator before the interface is displayed. It is best to install the translator immediately after the app.
Bytes --------------------------------------------------------------------------------------------------------------------
I tried it on my own machine and found that this conclusion is not applicable on my platform (qt3.1.1). You do not have to install a translator in front of the interface.