qt - QCompleter for large models -


qcompleter works slow on large data sets (large models): when start input characters in qcombobox passes few seconds show auto-complete popup variants, when input 2nd char qcompleter not react on key press few seconds well. next characters works fine. model size 100k records. possible improve qcompleter performance or show popup after 2nd or 3rd input symbol? there examples?

solution appears similar this: https://stackoverflow.com/a/33404207/630169 qcompleter uses qlistview in popup(). full solution speed-up qcombobox is:

tweak combo:

void comboboxtools::tweak(qcombobox *combo) {   //  performance reasons use policy on large models   // or adjusttominimumcontentslengthwithicon   combo->setsizeadjustpolicy(qcombobox::adjusttominimumcontentslength);    // improve combobox view performance   tweak((qlistview *)combo->view());    // improve combobox completer performance   tweak(combo->completer()); } 

tweak dropdown/popup (view):

void comboboxtools::tweak(qlistview *view) {   // improving performance:  possible give view hints   // data handling in order improve performance   // when displaying large numbers of items. 1 approach can taken   // views intended display items equal sizes   // set uniformitemsizes property true.   view->setuniformitemsizes(true);   // property holds layout mode items. when mode batched,   // items laid out in batches of batchsize items, while processing events.   // makes possible instantly view , interact visible items   // while rest being laid out.   view->setlayoutmode(qlistview::batched);   // batchsize : int   // property holds number of items laid out in each batch   // if layoutmode set batched. default value 100.   // view->setbatchsize(100); } 

tweak completer:

void comboboxtools::tweak(qcompleter *completer) {   completer->setcasesensitivity(qt::caseinsensitive);   // if model's data completioncolumn() , completionrole() sorted   // in ascending order, can set modelsorting property   // casesensitivelysortedmodel or caseinsensitivelysortedmodel.   // on large models, can lead significant performance improvements   // because completer object can use binary search algorithm   // instead of linear search algorithm.   completer->setmodelsorting(qcompleter::casesensitivelysortedmodel);    // improve completer popup (view) performance   tweak((qlistview *)completer->popup()); } 

Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -