The main view of my application contains a one-level (no children) QTreeView that displays on average 30,000 items. Due to the way the items are created, they are inserted into the model unsorted. This means that on application startup I have to sort the items in the view alphabetically, which takes nearly 1 second, leaving an unresponsive grey screen until it is done. (Since the window hasn't painted yet)
Is there any way I could get the sorting of a QSortFilerProxyModel into a separate thread, or are there any other alternative ways to approach this problem?
Here's my lessThan() code, for reference: (left and right are the two QModelIndexes passed to the function)
QString leftString = left.data(PackageModel::NameRole).toString();
QString rightString = right.data(PackageModel::NameRole).toString();
return leftString < rightString;
Thanks in advance.