All you have to do is define a new role with the value > Qt:: UserRole, then call setData() with the string you want to add and the new role.It is not clear to me how to add data with a custom role.
In the code you have posted above, the only time you save anything is when the role == EditRole. If you want setData() to save your string when the role == UserRole + 1, you must add an if () clause for that.
QTableView does not know anything about user roles so it will never ask for it, but you can call data() on your model (or the model index) with this role whenever you want to get the value for your custom role.




Reply With Quote
Bookmarks