QListView and big database - bad performance
Hi,
I have problem with performance QListView.
For add items I used this function
Code:
void MainWindow
::addToModel(const QString &path
) {
item->setIcon( icon );
item->setText( path );
dirModel.appendRow( item ); // QStandardItemModel
}
It work fine but when I try add 200 000 items my application froze for 3-4 seconds.
What I already done is
Code:
setUniformItemSizes( true );
What can I do to speed up this process?
Re: QListView and big database - bad performance
Maybe use QFileSystemModel?
Cheers,
_
Re: QListView and big database - bad performance
Besides the fact that no one is going to look at a list view containing 200,000 items (Do you seriously think any user will do that? Would you?), the way you are appending to the model probably is causing (1) the model to resize itself frequently and (2) the list view to redraw itself (and maybe sort) with each new entry.
If you know in advance how many things you are adding, then set the rowCount() on the model first, then use setItem() instead of appendRow().
You could also create all of the QStandardItem instances, put them in a QList<> and add them all at once with insertColumn() or appendColumn(). Remember that with a QListView, you only get one column.