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

editable ComboBox loses editText value on model changes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P3: Somewhat important
    • None
    • 6.5.3, 6.7.0
    • Quick: Controls 2
    • None
    • All

    Description

      It is not possible to assign editText value, because it is unset on model data changes. This makes editable ComboBox useless in my situation. And there are no workarounds.

      import QtQuick
      import QtQuick.Controls
      
      Window {
          width: 640
          height: 480
          visible: true
          Column {
              // OK no model
              ComboBox {
                  editable: true
                  currentIndex: -1
                  editText: "Qt Test"
              }
              // FAIL simple model
              ComboBox {
                  editable: true
                  currentIndex: -1
                  editText: "Qt Test"
                  model: 5
              }
              // FAIL simple model 2
              ComboBox {
                  editable: true
                  currentIndex: -1
                  editText: "Qt Test"
                  model: ["cat", "dog"]
              }
              // FAIL advanced empty model
              ComboBox {
                  editable: true
                  currentIndex: -1
                  editText: "Qt Test"
                  model: _model
              }
              // INITIALLY ok, because delayed assignment, but FAIL when new item added with button
              ComboBox {
                  editable: true
                  currentIndex: -1
                  Component.onCompleted: editText = "Qt Test"
                  model: _model
              }
              Button {
                  text: "ADD"
                  onClicked: {
                      _model.append({text: "cat"});
                  }
              }
          }
          ListModel {
              id: _model
          }
      } 

      Even if text is changed via keyboard and "ADD" pressed, then value is lost again.

      Attachments

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

        Activity

          People

            axelspoerl Axel Spoerl
            chocis Janis Coders
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes