Yes, these are both correct answers. For a table, you generally won’t need to use internalPointer(). What you are doing in your example code is correct.
If you need to use internalPointer(), then calling createIndex() is what you need to do. The createIndex() function takes three arguments: row, column, object. The third argument, that I call “object”, can be either a unique id or an arbitrary object. When you call internalPointer() on a QModelIndex, the “object” that was assigned in the call to createIndex() is the one that will be returned.
Every index in your model must have a unique combination of (row, column, object). For tables and lists, “object” can be the same for every call to createIndex() because (row, column) is unique. (Notice that I said it can be the same. It does not have to be the same.) But for a tree, (row, column) might be found in multiple places. For example, a tree might have a node (row=1, column=0) parented to the root node. That node might also have children nodes, including one at (row=1, column=0). Each of these instances must have a unique object to point to.