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

QQC2 ComboBox textAt() fails with some models

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15
    • Quick: Controls 2
    • None
    • Linux, Qt built from 5.15 branch
    • All

    Description

      class Foo {
          Q_GADGET
          Q_PROPERTY(QString bar MEMBER bar CONSTANT)
          QString bar = "Hello";
      };
      
      class Bar : public QObject {
          Q_OBJECT
          Q_PROPERTY(QVariantList foos MEMBER foos CONSTANT)
      
          QVariantList foos{QVariant::fromValue(Foo{}),QVariant::fromValue(Foo{})};
      };
      
      ComboBox {
          model: Bar.foos
          textRole: "bar"
          onCurrentIndexChanged: console.log(textAt(currentIndex))
      }
      

      textAt(currentIndex) always returns an empty string, which results in the combobox displaying an empty string. The delegates however display the string properly.

      Replacing the QVariantList model with other types of models works fine though

       

      ComboBox {
          model: ["Foo", "bar"] // Works fine
          onCurrentIndexChanged: console.log(textAt(currentIndex))
      }
      
      
      ComboBox {
          model: [{bar: "Hello", foo: "Foo"}] // Works fine
          textRole: "bar"
          onCurrentIndexChanged: console.log(textAt(currentIndex))
      }
      

       

       

      Attachments

        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
            nicolasfella Nicolas Fella
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes