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

Add valueRole to ComboBox

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P3: Somewhat important
    • 5.14.0 Alpha
    • 5.12.0
    • Quick: Controls 2
    • None
    • f462312365d4955fc82b247b72f84e1c77d8104d (qt/qtquickcontrols2/dev)

    Description

      ComboBox already has a textRole, to simplify user code when dealing with a model having multiple roles, ComboBox should also have a valueRole.

      We could add these properties and function:

      • writable valueRole : similar to textRole
      • readonly currentValue: similar to currentText
      • findValue function: similar to the find function

      Usage could then be:

      ComboBox {
          model: [ {value: SomeEnum.One, text: "One"}, {value: SomeEnum.Two, text: "Two"}]
          textRole: "text"
          valueRole: "value"
          currentIndex: findValue(someBusinessObject.value)
          onActivated: someBusinessObject.value = currentValue
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              mitch_curtis Mitch Curtis
              grecko Pierre-Yves Siret
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes