Results 1 to 4 of 4

Thread: Question about QCompleter

  1. #1
    Join Date
    Jun 2007
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Question about QCompleter

    Hello All
    Is it possible to use QCompleter with a QLineEdit which has an input mask?

    Regards

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about QCompleter

    Why not? I don't see any reason why you couldn't do that.
    Why don't you just try it? It's not a big deal to write it.

  3. #3
    Join Date
    Jun 2007
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation Re: Question about QCompleter

    Hello Marcel
    Thanks for your reply. I have tried it, but I could not manage to solve the problem.
    Here is the code:

    Qt Code:
    1. completer = new QCompleter (keys, this);
    2. completer->setCaseSensitivity (QCompleter::CaseSensitive);
    3. completer->setCompletionMode (QCompleter::PopupCompletion);
    4. LineEdit->setInputMask ("NNNNN-NNNNN-NNNNN-NNNNN;_");
    5. LineEdit->setCompleter (completer);
    To copy to clipboard, switch view to plain text mode 

    The keys variable contains a list of serial keys that are of the form specified as the mask. Unfortunately, the completer does not work. Any suggestions?

    Best Regards

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Question about QCompleter

    The problem is that QLineEdit feeds QCompleter with its text without taking input mask into consideration. In your situation, typing for example "A" passes "A____-_____-_____-_____" to the completer, which naturally matches none of the serials. What you could try is to use QCompleter::UnfilteredPopupCompletion. I know it doesn't work very well either but at least it shows something.

    PS. You could send a suggestion to the Trolls via task-tracker. At least I think that it would be a nice option to have that no useless input mask characters would be passed to completer. Of course, it should only pass everything up till the first empty character in case one enters one character here and another there, like "A____-B____-_____-_____" would pass "A".
    J-P Nurmi

Similar Threads

  1. a smarter QCompleter
    By ber_44 in forum Qt Programming
    Replies: 7
    Last Post: 30th March 2011, 07:10
  2. Replies: 1
    Last Post: 15th March 2007, 20:45
  3. QCompleter + QSqlTableModel problem
    By Lykurg in forum Qt Programming
    Replies: 2
    Last Post: 11th March 2007, 20:59
  4. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34

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.