Search code examples
qtdesign-patternsmodel-view

Qt Model/View programming with complicated data structures


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.


Solution

  • 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.