Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Dynamic locale change



  • Hello There,
    I have a requirement to change the locale at run time.
    I am aware of following mechanism,

    1. Remove the existing translator insatalled
    2. install new translator according to the locale selected
    3. Handle the Language change Event

    In the language change event, I can set any static text under TR macro and it displays according to the locale selected.

    Since I have many widgets in my application,
    My question is, if I have a QPushButton with static label. Is it possible to change the label automatically (other than the steps I mentioned above)? OR one has to catch the language change event and once again set the text so that it gets localized?

    Thanks
    SPanara



  • @spanara
    I would assume you will have to do your steps --- how else would the button know to change its text?

    But with your "many widgets" you should not have to write code for each widget to handle this/update itself. You should be able to loop over all of them doing the updates in one go.


Log in to reply