How can i associate a GUId for each row i create in QTableView
-
Hi
I want to associate a GUID for each row i create in QTableView.
So that i can retrieve it back when user clicks on particular row.How to do this?
-
Have the underlying model create one.
It seems overkill for me to use a GUID for a row in a table though.
-
Hi Andre
I want to associate some string data to each row so that i can fetch it back when user clicks the row and use that string for further processing.
How to do this?
-
What model do you use? The basic way to do it is to just use a custom role (Qt::UserRole+n), and make your model return the needed data when asked for it for the current index. How you do that exactly, depends on the model you use.
-
HI Andre
I use QStandardItemModel.
-
In that case, use QStandardItem::setData().
Note that you'll have to do that for every item on the row, you will have to subclass QStandardItemModel to return the value from the first column for this role for every column, or something like that. You'd have to reimplement the data() method for that. -
Hi Andre
Can you please help me to show how to do it.
-
No, now it is your turn to show what you have tried. I have no interest in doing your work or school assignment for you.