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

Virtual keyboard locale settings triggers geometry change then languageListModel count update and results in binding loop

    XMLWordPrintable

Details

    Description

      A minimal reproducer is attached. It is nothing more than a template project generated by Qt Creator, except that the following locale settings are added to InputPanel:

              Component.onCompleted: {
                   VirtualKeyboardSettings.activeLocales = ["en_US", "ja_JP"];
                   VirtualKeyboardSettings.locale = "en_US";
              }
      

      I suppose it is a fairly common and reasonable way to set desired locales and default locale? But the very moment you click on the little "Earth" icon to try to change input method, the following warning happens:

      qrc:/qt-project.org/imports/QtQuick/VirtualKeyboard/Components/Keyboard.qml:1209:9: QML PopupList: Binding loop detected for property "preferredVisibleItems":
      qrc:/qt-project.org/imports/QtQuick/VirtualKeyboard/Components/PopupList.qml:9:5
      qrc:/qt-project.org/imports/QtQuick/VirtualKeyboard/Components/Keyboard.qml:1209:9: QML PopupList: Binding loop detected for property "preferredVisibleItems":
      qrc:/qt-project.org/imports/QtQuick/VirtualKeyboard/Components/PopupList.qml:9:5
      

      That warning points to PopupList.qml which is the ListView that shows the active locales. The problematic lines include the property that causes the binding loop:

          readonly property int preferredVisibleItems: count < maxVisibleItems ? count : maxVisibleItems
      

      And the property that "kicks off" the loop:

          height: currentItem ? currentItem.height * preferredVisibleItems + (spacing * preferredVisibleItems - 1) : 0
      

      In short, the problem is that height (geometry of ListView) depends on preferredVisibleItems which in turn depends on count which gets updated when ListView geometry gets updated. Something like:
      geometry change -> count change -> preferredVisibleItems change -> geometry change -> loop.

      It can also be seen from part of the stack trace (the stack trace is not from the minimal reproducer I provided here but the idea is the same):

      Frame 20: geometry change
      Frame 11: refill (the method to be questioned: it interfaces geometry and count)
      Frame 9: count change
      Then it is the property bindings in PopupList.qml that gets the loop going.

      Anyway, I think the main problem here is: why count should change according to geometry? Isn't the count of a ListView simply "how many entries are there in the model"? Maybe it is more of a QtQuick.Controls issue than virtual keyboard issue. If so, feel free to reassign and relabel this report.

      Update: you don't even need both locale settings. "VirtualKeyboardSettings.activeLocales" alone is enough to cause the binding loop. On the other hand, specifying "VirtualKeyboardSettings.locale" is OK.

      Attachments

        1. image-2025-06-26-15-39-06-647.png
          527 kB
          Luqiao Chen
        2. QTBUG138050.7z
          1 kB
          Luqiao Chen
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jakoivik Jarkko Koivikko
            luqiaochen Luqiao Chen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes