QAbstractProxyModel work with QPersistentModelIndex to create internal maps of items. I am assuming your TreeToTableProxyModel is QAbstractProxyModel inherited and not QSortFilterProxyModel.
Given your problem why don't you make your original model class run in two modes. Tree mode and flat mode. Define your index() and parent() functions according to the mode set. While changing the mode do a model reset.