I have got a problem with multi language qt (change language on the fly). My form have a combobox which should be translated when language changed. When languageChanged, the app call method retranslateUi() to translate item in the combobox. The combobox have slot corresponding for signal currentIndexChanged().
void on_comboBox_currentIndexChanged(int index)
{
//do something
}
void on_comboBox_currentIndexChanged(int index)
{
//do something
}
To copy to clipboard, switch view to plain text mode
But when method retranslateUi() called, I do this:
void retranslateUi()
{
ui->comboBox->clear();
);
}
void retranslateUi()
{
ui->comboBox->clear();
ui->comboBox->insertItems(0, QStringList()
<< QApplication::translate("SettingDialog", "English", 0, QApplication::UnicodeUTF8)
<< QApplication::translate("SettingDialog", "French", 0, QApplication::UnicodeUTF8)
);
}
To copy to clipboard, switch view to plain text mode
Problem is: each statement in retranslateUi() will emit the signal currentIndexChanged(), then the slot will call again.
How can I avoid that ?
Bookmarks