Reputation: 4450
I am not a professional application developer so am probably not as familiar with the model/view design pattern as I should be. Nonetheless, I am trying to use it in a hobby app and failing miserably. The primary problem I am having is that the data I am trying to display and modify is not easily represented with an extension of QAbstractItemModel
.
The data I am trying to encapsulate is essentially a growable/shrinkable, mutable list of integers. Should I abandon the model/view pattern for data like this? It seems more appropriate when the "dimensions" of the data are fixed. If not, is there an example of an implementation that I could take a gander at, or a good book that I should pick up?
Regards.
Upvotes: 2
Views: 3518
Reputation: 3698
I would look at QAbstractListModel. It sounds like a more relevant model than the basic QAbstractItemModel
.
There is also a rather different view of that model in the example: Puzzle
If you need a higher level look at Model/View, check out this.
Upvotes: 3
Reputation: 79011
QAbstractItemModel
is just one, admittedly very limited way of implementing the Model/View design pattern. If you see that your situation doesn't fit it neatly don't bother working too hard to force it.
A better approach for you would probably be to just pull your own Model class with your own View classes and abandon QAbstractItemModel
. There is more to this design pattern than the weird flavor implemented in QT and that flavour only works well for very particular applications.
I suggest you read about it some more and design your own Model-View setup. Your class design is very likely to be cleaner and better understood if you pull your own.
Upvotes: 0