So I've got a QSortFilterProxyModel with a QAbstractTableModel underneath.

Before I sort the table, inserting rows works fine. If I put a row in at 3, for example, 3 moves to 4, etc.

Once I sort the table however, inserting a row always goes at the end of the beginning and this behavior appears random. Is there a good way of doing this? Here's what I've tried:

* Using mapToSource. Unfortunately, since the index doesn't exist yet, this doesn't work.
* The default method, QSortFilterProxyModel::insertRows. This fails as described above.

I've tried looking at Qt's source code as well and it appears that I'd need to basically create a mapping inside the proxy model for the correct index before creation, but I'm not quite sure how to do that using the public API. I'll keep looking, but if anyone can help me out here, I'd appreciate it