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

ComboBox.qml (QQC2) does not set the proper index using the "currentIndex" property

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.11
    • Quick: Controls 2
    • None

      So the following does NOT work as you would expect:

       

      ComboBox {
           id: race
           model: ["I choose not to answer","American Indian or Alaska native",
       "Asian", "Black or African American", "Polynesian","White","Other"]
           currentIndex: race.find("Asian");
       }

       

      as it would actually make the ComboBox blank rather than select the "Asian" option. My current workaround is this:

       

      ComboBox {
           id: race
           model: ["I choose not to answer","American Indian or Alaska native",
       "Asian", "Black or African American", "Polynesian","White","Other"]
           Component.onCompleted: race.currentIndex = race.find("Asian");
       }
      

       

      Which will properly set the ComboBox to "Asian". I assume this is because the "currentIndex" property is called before the model is actually set.  I assume this is more of a bug rather than intended function of ComboBox.

       

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            tshah Tej Shah
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes