Changing Language at runtime ?
-
wrote on 4 Aug 2013, 11:27 last edited by
Hi ,
I am stuck at a particular point and need some suggestions about handling multi language support for my application. I have a class that takes an integer value and returns a QString. The values comes from a text file that contains name value pairs like 1234 = ABCD which are read and stored in a QHash.
For the components/widgets the text values are stored file
@m_widget->setText(SomeClass::getText(1234,"ABCD"); // "ABCD" - default text if 1234 is not found@
Now for all my widget I have implemented changeEvent() where I am checking for LanguageChange event and there I call setText() which works perfect. In order to emit LanguageChange I installed a QTranslator on qApp.Now my question is how to handle other things, like text value in a textEdit or the items in a QCombobox and other widgets as well ?
-
Hi,
It seems that you would have to either "reload" the widgets if the text are set within the specific widget or handle the LanguageChange from the "containing" widget that sets the text/items etc... (I am not sure if what I said is clear...)
-
wrote on 5 Aug 2013, 07:35 last edited by
Thanks,
I understood but the question is how to proceed with it. I have implemented the base structure at component level.
For the modules that I have to reload every widget as the they are initialized and loaded in the constructor. If I reload all again then it will be a hectic job for each n every module and also for all the projects O_o
-
Do you use only widgets you created and standard Qt widgets ?
-
wrote on 5 Aug 2013, 08:32 last edited by
I have my own Ui library, where I have subclassed most of the Qt widgets. So for my projects I am using these custom widgets only.
-
Then you could move the text setting part in its own function and call it from the constructor and from the changeEvent of your widgets
1/6