I’m searching for a way to save integers and strings in a model and add new ones/ remove them. Maybe I will use QStyledItemDelegate soon too, so it needs to be a compatible solution.
I have some Integers and Strings in a Qsqltable. Next, I want to add a custom row (should only be added to my model, not to the database). As far as I know, QStandarditemmodel does only support Strings. The final goal is to show the data on a tableview or/and listview.
I tried to solve with QStandarditemmodel and setData() wich supports QVariant. But I guess the “data” is only for background information.
Advertisement
Answer
After some years of experience, I got the answer: QStandardItemmodel is the best solution for such a need. I didn’t knew a lot about Roles back then, so I didn’t knew about DisplayRole, wich would have solved my problem.