This thread is 6 years old but appears in Google, so I'll hint to the probable solution for future readers.
If you move items the way you do it, you will invalidate your view's internal persistentModelIndices for selected items, current item etc. Next time such a persistent index will be fed to your model's data() function, it will segfault.
For sorting / rearranging items you need to either
beginResetModel();
sortItems();
endResetModel();
beginResetModel();
sortItems();
endResetModel();
To copy to clipboard, switch view to plain text mode
or
for(row in all items) {
toRow = sortRow(row); // or whatever
beginMoveRows(row, toRow);
moveItem(row, toRow);
endMoveRows();
}
for(row in all items) {
toRow = sortRow(row); // or whatever
beginMoveRows(row, toRow);
moveItem(row, toRow);
endMoveRows();
}
To copy to clipboard, switch view to plain text mode
Bookmarks