Results 1 to 9 of 9

Thread: FAster approach for Completetion

  1. #1
    Join Date
    Apr 2009
    Posts
    206
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default FAster approach for Completetion

    Hello Friends,

    I experiment with the standard approach for implementing QCompleter in a QLineEdit.
    But when the wordlist grows up to 20000 or more the delay before the popup widget for completetion comes ist to long.

    Is there another aproach for implementing completetion with big amount of words?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: FAster approach for Completetion

    Are you using a QStringListModel? If so, create a SQLite database in the memory, or if the wordlist wont change on your disk, and use that with a QSqlTableModel. This will speed up the process.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: FAster approach for Completetion

    Someone should really write a completer class based on a suffix (or prefix) tree...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Apr 2009
    Posts
    206
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default Re: FAster approach for Completetion

    I use this:

    Qt Code:
    1. QCompleter *completer = new QCompleter(qstrL_mylist, this);
    2. completer->setCompletionMode(QCompleter::PopupCompletion);
    3. qle_myLineEdit->setCompleter(completer);
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: FAster approach for Completetion

    then, as told, try to use a sqlite database.

  6. #6
    Join Date
    Apr 2009
    Posts
    206
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default Re: FAster approach for Completetion

    so now I implement this one:

    Qt Code:
    1. model->setTable("mytable");
    2. model->select();
    3. QCompleter *completer = new QCompleter(model, this);
    4. completer->setCompletionMode(QCompleter::PopupCompletion);
    5. completer->setCompletionColumn(0);
    6. qle_myLineEdit->setCompleter(completer);
    To copy to clipboard, switch view to plain text mode 

    now the delay is ca. 0.3 seconds by 40000 words feels ok or exists there a better approach??

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: FAster approach for Completetion

    You can implement your own completer class based on Patricia trie and optionally populated in a worker thread with caching completion traces (so that removing the last character of completion prefix doesn't cause the completion list to be rebuilt). That's pretty much maximum you can squeeze from a completer mechanism.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    codeman (22nd July 2010)

  9. #8
    Join Date
    Apr 2009
    Posts
    206
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default Re: FAster approach for Completetion

    Patricia trie ???????

  10. #9
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: FAster approach for Completetion

    Quote Originally Posted by codeman View Post
    Patricia trie ???????
    Google is your friend: http://en.wikipedia.org/wiki/Radix_tree!

  11. The following user says thank you to Lykurg for this useful post:

    codeman (22nd July 2010)

Similar Threads

  1. a faster QSqlQueryModel::data()
    By baray98 in forum Qt Programming
    Replies: 0
    Last Post: 24th September 2009, 00:56
  2. Faster paintEvent
    By SailinShoes in forum Qt Programming
    Replies: 1
    Last Post: 1st October 2008, 15:25
  3. Faster code possible?
    By ShaChris23 in forum General Programming
    Replies: 1
    Last Post: 28th May 2008, 07:35
  4. what is the best approach
    By baray98 in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2007, 09:02
  5. faster QScrollView
    By firas in forum Qt Programming
    Replies: 2
    Last Post: 29th April 2006, 18:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.