PDA

View Full Version : QCompleter performance for large data models



jpmgr
9th June 2014, 09:25
I was working with the completer example( that comes with Qt installation; C:\Qt\Qt5.3.0\Examples\Qt-5.3\widgets\tools\completer). It was working fine for the small text file wordlist.txt.But if I change wordlist.txt file with a textfile which has 200k words then there are significant delay in the popup completion box showing up. How do I remove this delay and show up the popup box instantly?( I need to show only 100 results in the popup box in every keystrokes in the QLineEdit.

wysota
9th June 2014, 09:32
I'm afraid you'll have to build your own completer tailored for your model characteristics. Going through 200k entries takes time, you have to reduce that time somehow (e.g. using some kind of trie if your usecase allows it).

jpmgr
9th June 2014, 09:43
I have done that for a DOTNET based project where the data is fetched from a List<string> and shown up in a ListBox almost instatly(250K words). However in DotNet there is a BeginUpdate and EndUpdate method of the ListBox so that the updation of the ListBox with new results while the user types is smooth. Is there any equivalent method for QListView?

wysota
9th June 2014, 10:22
Updating of the view is unlikely the problem, filtering the model is the bottleneck. Apparently upon each change in the text the whole model is refiltered. What you need to do is either track changes or provide a faster than linear way of filtering the model. Unfortunately the latter cannot be done by subclassing QCompleter so you will have to provide your own completer class for that.

AlekseyK
31st October 2015, 17:09
You can find FULL solution for such situation here: http://stackoverflow.com/a/33454284/630169