I’m about to implement something similar to : http://doc.qt.nokia.com/latest/itemviews-simpletreemodel.html
I have a type, aosl::Object, that contains all the data of a node in a tree of Objects.
I want to display some informations in a QTreeView. So it seems I need to implement a class inheriting from QAbstractItemModel to allow the views to exploit the data. So far so good. That class would be like the TreeItemModel class in the example.
However, in the example, they also implement a TreeItem class that seems to hold the data required for the tree node. It is not a QObject or something associated with Qt – that’s where my doubt comes from.
So the question is : do I need to have another type than my aosl::Object type inside my QAbstractItemModel, or can I use it as is withtout having to add another “item” type?
QAbstractItemModel’s external interface is operating soley on QModelIndex and QVariant – no internal structure is exposed to view class. As long as your class (aosl::Object) can provide all information required in implementation of your QAbstractItemModel decenant you don’t need to wrap it into QObject, or anyhow else.