This works when I use a number (256 for Qt::UserRole) but not with an enum name

> Am 09.05.2016 um 16:47 schrieb Nikita Krupenko <krne...@gmail.com>:
> 
> 2016-05-09 17:32 GMT+03:00 NoRulez <noru...@me.com>:
>> I have a QStandardItemModel
>> 
>> I also to overload the roleNames() function but then i get the error that 
>> "Role2" isn't defined.
>> 
>> 
>> 
>>> Am 09.05.2016 um 15:50 schrieb Nikita Krupenko <krne...@gmail.com>:
>>> 
>>> 2016-05-09 9:19 GMT+03:00 NoRulez <noru...@me.com>:
>>>> Hi,
>>>> 
>>>> I want do show data in a combobox in QML and after a selection in the 
>>>> combo box is made I want the data but from a different role.
>>>> 
>>>> In QML I have the following:
>>>> 
>>>> ComboBox {
>>>> model: MyModel
>>>> textRole: "Role1"
>>>> onCurrentTextChanged: {
>>>>       MyLineEdit.text = ?????? // Here I want the text from "Role2"
>>>>   }
>>>> }
>>>> 
>>>> MyLineEdit is a QML LineEdit
>>>> The text for "Role1" works already.
>>>> Could anybody please give me a help
>>>> 
>>>> Thanks
>>>> _______________________________________________
>>>> Interest mailing list
>>>> Interest@qt-project.org
>>>> http://lists.qt-project.org/mailman/listinfo/interest
>>> 
>>> AFAIK, you have ho access to model data in ComboBox. But, you can get
>>> it directly from model, like:
>>> 
>>> MyLineEdit.text = MyModel.get(currentIndex)["Role2"]
>>> 
>>> if you use ListModel, or some similar way if you have different model.
> 
> So, you need to use data() method. But you need to pass here
> QModelIndex, which you could get only from DelegateModel, which not
> used here :) I think, you can add to your model method, that return
> data by an integer index and use it here.
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to