Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15
-
None
-
Linux, Qt built from 5.15 branch
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)) }