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

QComboBox index and userdata lost when retranslateUI() called

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.6.0, 5.7.0, 5.8.0, 5.9.0
    • Fix Version/s: 5.9.2
    • Component/s: Build tools: uic
    • Labels:
      None
    • Environment:
      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?

        Attachments

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

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes