The execution of this simple snippet:
{
QModelIndexList sel = ui->tableView->selectionModel()->selectedRows(0);
sel.at(0).isValid(); // To prevent removing the previous line by optimization
}
takes more than 30 seconds when the number of selected rows is about one million. The construction of QModelIndex list is almost immediate, but the destruction takes forever. The time is spent in this function :
template <typename T>
Q_INLINE_TEMPLATE void QList<T>::node_destruct(Node *from, Node *to)
{
if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic)
while(from != to) --to, delete reinterpret_cast<T*>(to->v);
else if (QTypeInfo<T>::isComplex)
while (from != to) --to, reinterpret_cast<T*>(to)->~T();
}
Does somebody has a solution? Is there any way to get indexes of selected rows without creating QModelIndexList
, or can I speedup the destruction somehow?