For option 2 you would add a method for getting an index of the model for a given ID.

You could do that outside the model but it is probably more convenient to put it into the model class.

Something like

Qt Code:
  1. QModelIndex MyCustomModelClass::indexForID(int id) const
  2. {
  3. for (int i = 0; i < data.count(); ++i) {
  4. if (data.at(i).id == id) {
  5. return index(i, 0);
  6. }
  7. }
  8.  
  9. return QModelIndex();
  10. }
To copy to clipboard, switch view to plain text mode 
I.e. find the row the person with the given ID is in, return the model index for that row.
"data" is your reference to the MyAllData object, assuming that it can be queried for number of entries and can be asked for a specific entry.

You could also have a findById function in the data class and then use its return value to create the index, etc.

Cheers,
_