All the Model-View Interface Implmentations should check for QModelIndex ::isValid() condition and handle it accordingly (safely)

Example:
Qt Code:
  1. int ListModel::rowCount(const QModelIndex &parent) const
  2. {
  3. if(parent.isValid())
  4. return _data->count(); //root node
  5. else
  6. return 0;
  7. }
To copy to clipboard, switch view to plain text mode