Quote Originally Posted by rubikon View Post
But the function is getting called with index.row() = -1. Why gets the function called with index.row() = -1?
I still get the same error. What am I doing wrong?
Because an index can be invalid see QModelIndex::isValid.
So, you should at first check the index validity
Qt Code:
  1. ...
  2. if (!index.isValid())
  3. return 0;
  4. ...
To copy to clipboard, switch view to plain text mode