Qt uses QModelIndex to access the Model data.This needs to be able to access any part of the model, and these are likely to vary depending on the part of the model being referenced. My technique for overcoming this situation is based on the following implementation ideas
1. All class objects referenced from QModelIndex are descended from a common base class
2. All class objects referenced from QModelIndex have a unique ID that can be accessed from the base class via an overriden base class function
3. The QModelIndex internal pointer points to the base class
4. The base class can either implement/mirror the parent child relationships
The model implementation overrides virtual functions in QAbstractItemModel which need to be handled for any part of the model. Using the ID implementation it is an easy matter to resolve which part of the model is being referenced.
Finally, I used specialised template functions for handling different parts of the model being referenced using QModelIndex. This was the solution I used when developing the GUI for a subset sum application.
JB