I have few comboboxes with very dig data sets within ~ 100K rows and more. I tried it with QStandardItemModel
- works fast enough if model is preloaded, also model loading takes few seconds if performed in separate thread. Tried comboboxes with QSqlQueryModel
without threading to improve performance but experienced it works much slower than QStandardItemModel
(in our project QSqlQueryModel
works very fast with such amount of data with QTreeView
for example). What could be the problem here? Is there a way to speed-up combobox, some parameters?
P.S. Suggested by Qt doc QComboBox::AdjustToMinimumContentsLengthWithIcon
does not speed things much: dialog with such combos starts too long and exits 10-20 sec. AdjustToMinimumContentsLength
works a little bit faster but anyway delays are too long.
Found the solution. 1st thought was to find what model will work faster, for example
QStringListModel
to replaceQStandardItemModel
orQSqlQueryModel
. However seems that they work almost same speed. 2nd I found in Qt doc that combobox by default usesQStandardItemModel
to store the items and aQListView
subclass displays the popuplist. You can access the model and view directly (withmodel()
andview()
). That was strange for me as I knowQTreeView
works just fine with even bigger amount of data, and simplerQListView
also inherited fromQAbstractItemView
should do this as well. I start to digg intoQListView
and found properties in it which had solved the problem: now combobox opens immediately on large amount of data. Static function was written to tweak all of such combos (comments with explanation are from Qt doc):