I have a simple app that first asks for language (I have already done the qm and ts files) and it works:
//main.cpp
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator T;
QStringList langs;
langs << "Espanol" << "English" << "Deutsch";
const QString lang = QInputDialog::getItem(NULL, "Language", "Select a language", langs);
if (lang == "English"){
T.load(":/ingles.qm");
} else if (lang == "Deutsch"){
T.load(":/aleman.qm");
}
if (lang != "Espanol"){
a.installTranslator(&T);
}
a.setStyle("fusion");
MainWindow w;
w.show();
return a.exec();
}
But I want to change the language with radioButtons inside the MainWindow, is it posible for example to do it in the mainwindow.cpp in?:
void MainWindow::on_botoncambiaridioma_clicked()
{
if (ui->radioButton_2->isChecked()){
}
if (ui->radioButton_3->isChecked()){
}
}