Exactly as "Qt Centre wiki" said:In many situations roles mentioned earlier are not sufficient to store or retrieve all the data associated with an item. In this situation model designers can create new roles and assign data to them. I need new role to expand the item data.
Before I read the wiki, I define new role like this const int DisplayTypeRole = 32; and In data() and setData(), I write code to deal with the custom role in "switch sentences", and the behavior of the program looks well.
But I really donnot know why I need to redefine this function : QMap<int, QVariant> itemData ( const QModelIndex & index ) const. What is in the structure QMap<int, QVariant>? All the Model's data? Please give me a clue.![]()
Bookmarks