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

QML Dialog standard buttons not retranslated under Windows OS

    XMLWordPrintable

Details

    • Windows

    Description

      Under Windows OS(Under MacOS it works well) QML dialog standard buttons like 'OK', 'Cancel' etc are not retlanslated after the new language is chosen. Below is the minimal reproducable  example:

      Qml part with the combo box with 2 languages:

      import QtQuick
      import QtQuick.Controls
      
      Window {
        width: 400
        height: 400
        visible: true
      
        Dialog {
          id: dialog
          width: 300
          height: 300
          anchors.centerIn: parent
          visible: true
          contentItem: Item {
            ComboBox {
              anchors.centerIn: parent
              model: ["ru", "en"]
              onCurrentTextChanged: {
                translator.setLanguage(currentText)
              }
            }
          }
      
          standardButtons: Dialog.Ok | Dialog.Cancel | Dialog.Apply
        }
      }
      

      and the cpp part with the translation logic:

      void Translator::setLanguage(const QString& languageCode)
      {
          const auto qtTrDir = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
          const auto wasEmpty = qtTranslator_.isEmpty();
          assert(qtTranslator_.load(QString\{"qt_%1.qm"}.arg(languageCode), qtTrDir));
      
          if (wasEmpty) {
              assert(QCoreApplication::installTranslator(&qtTranslator_));
          }
      
          engine_->retranslate();
      }
      

      Full code in the attached archive

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            maksim_malofeev Maxim Malofeev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes