Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.6.0, 5.7.0, 5.8.0, 5.9.0
-
None
-
Windows 10
Qt 5.9.0
Qt 5.6.2
MSVC 2015
MinGW 5.3
Description
Similar to this bug (https://bugreports.qt.io/browse/QTBUG-42414).
Comboboxes are not retranslated correctly when you change the language during runtime. Currently, the uic produces in the retranslateUi() function the following:
comboBox_language->clear();
comboBox_language->insertItems(0, QStringList()
<< QApplication::translate("ConfigDialog", "English", Q_NULLPTR)
<< QApplication::translate("ConfigDialog", "German", Q_NULLPTR)
);
This procedure causes additional problems like:
- The userdata of the combobox items are lost, which have been added after the ui->setup()
- The index has been changed to another value without any obvious user interaction
- clear() as well as insertItems() trigger the currentIndexChanged() signal
But, when the combobox is setup with some icons in the Qt Designer, then the uic produces the following:
comboBox_language->setItemText(0, QApplication::translate("ConfigDialog", "English", Q_NULLPTR));
comboBox_language->setItemText(1, QApplication::translate("ConfigDialog", "German", Q_NULLPTR));
This seems the be correct to me, the index is not changed and user data is still available.
Why is this not the standard case, but just for the "combobox items with icons" case?