error: Unable to assign [undefined] to QString
-
@Lucas_1603 said in error: Unable to assign [undefined] to QString:
text: model_.title
What should that mean?
"Give me the title of the song in my playlist"?
Which song are you talking about? the first, the last, one in the middle? -
@Lucas_1603 said in error: Unable to assign [undefined] to QString:
text: model_.title
What should that mean?
"Give me the title of the song in my playlist"?
Which song are you talking about? the first, the last, one in the middle?@GrecKo The second song for example. The title is "Mysong2"
-
So you have to somehow tell that you want the second one.
You could add an invokable get method in your model return data from a specific row.
But if you need it to be updated when the model changes, it's going to be hard.I wrote a library for that https://github.com/oKcerG/QmlModelHelper , it works for any standard QAbstractItemModel.
You could use it like that:
text: model_.ModelHelper.map(1).title
-
@GrecKo The second song for example. The title is "Mysong2"
@Lucas_1603 for second song,
text:model_[1].title
-
@Lucas_1603 for second song,
text:model_[1].title
-
What @sharath proposed won't work. You can't access QAbstractItemModel's data with [].
@Lucas_1603 please better define what you want.
Do you want multiple text items for each of your songs? Or do you want all titles concatenated in one text? Or something else? -
@Lucas_1603 Create get method to get perticular index data from QAbstractListModel class. follow https://stackoverflow.com/questions/22711421/how-to-implement-qml-listmodel-like-get-method-for-an-qabstractlistmodel-derived .
i'm sure that your problem might solve with this link.Happy coding
-
What @sharath proposed won't work. You can't access QAbstractItemModel's data with [].
@Lucas_1603 please better define what you want.
Do you want multiple text items for each of your songs? Or do you want all titles concatenated in one text? Or something else?@GrecKo In ListView, I just need to specify the model and then I can assign
model_.title
, it'll display all titles concatenated in one text. I want do the same from the Text outside of ListView.
@sharath I actually created get method and it worked as I expected. Now I want to display all titles concatenated in one text. -
@GrecKo In ListView, I just need to specify the model and then I can assign
model_.title
, it'll display all titles concatenated in one text. I want do the same from the Text outside of ListView.
@sharath I actually created get method and it worked as I expected. Now I want to display all titles concatenated in one text.@Lucas_1603 said in error: Unable to assign [undefined] to QString:
@GrecKo In ListView, I just need to specify the model and then I can assign model_.title, it'll display all titles concatenated in one text.
No that's what it does, it creates a delegate for each row and position them the one after the other
I want do the same from the Text outside of ListView.
If you want the same why don't you want a ListView.
Maybe do a schema of what you actually want?
-
@Lucas_1603 said in error: Unable to assign [undefined] to QString:
@GrecKo In ListView, I just need to specify the model and then I can assign model_.title, it'll display all titles concatenated in one text.
No that's what it does, it creates a delegate for each row and position them the one after the other
I want do the same from the Text outside of ListView.
If you want the same why don't you want a ListView.
Maybe do a schema of what you actually want?
@GrecKo Great, I created another ListView and everything was done ^^
Thank you a lot. How about a schema as you said, can you give me some links or docs to learn more about it? Thanks