Lets have a look at that code:
Qt Code:
{ switch (e->type()) { ui->retranslateUi(this); break; default: break; } }To copy to clipboard, switch view to plain text mode
This function gets called when the main window received a change event. This can be all sorts of things, but in this case, the code specifically targets language changes (QEvent::LanguageChange). If the language changed, the UI gets automatically retranslated. Anything else gets handled by the main window itself.
This is needed because you add custom controls to your window. If you don't react on this change in your main window subclass, only the standard items of the main window get retranslated, but not your own controls.
Bookmarks