Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-61778

QComboBox index and userdata lost when retranslateUI() called

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.9.2
    • 5.6.0, 5.7.0, 5.8.0, 5.9.0
    • Build tools: uic
    • None
    • Windows 10
       Qt 5.9.0
      Qt 5.6.2 
      MSVC 2015 
      MinGW 5.3

      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?

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            jkobus Jarek Kobus
            stvokr stvokr
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes