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

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

    XMLWordPrintable

Details

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

    Description

      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.

       

      Attachments

        Issue Links

          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
              tshah Tej Shah
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes