I have a few questions about the models.

Say i have the following classes:
Qt Code:
  1. class SubItem {
  2. // some properties...
  3. };
  4.  
  5. class Item {
  6. // some properties...
  7. QList<SubItem> subitems;
  8. };
To copy to clipboard, switch view to plain text mode 

Now, i have a UI which displays those items. It is an MDI, where each window has a form layout which displays the properties of the Item.

Most of the properties can just be displayed on a QLabel, but for the list of subitems i need a list-based widget (QListWidget/QListView or QTableWidget/View).

Currently, i am just using the Q*Widget classes. But i would like to use proper model/view programming and use a Q*View.
The problem is that i am not sure how to use a list model in this case. I started to think about the class definitions and realised i have no idea how it will work:
Qt Code:
  1. class SubItem...
  2.  
  3. class Item {
  4. SubItemListModel getSubItemListModel();
  5. }
  6.  
  7. class SubItemListModel {
  8. Item* item; // A reference to the object which contains the list.
  9.  
  10. QList<SubItem> getItems() { item->getSubItems(); }
  11. }
To copy to clipboard, switch view to plain text mode 

Should the SubItemListModel work with the data in the Item's list, or should the Item have it's list data in a SubItemListModel?


Also another minor question - i have my UI classes defined in .cpp files in one folder, and my "model" (or data) classes (Item, SubItem, etc) defined in another folder. This is separation of data and ui. But if i were to start using Qt's model classes (derived from QAbstractItemModel), where would they be defined? With my data classes, or the UI classes? Because as i see it, Q*Models are more about providing data to the UI, rather than actually storing data themselves.