View Full Version : Question about QCompleter

15th October 2007, 21:27
Hello All
Is it possible to use QCompleter with a QLineEdit which has an input mask?


15th October 2007, 21:30
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.

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

completer = new QCompleter (keys, this);
completer->setCaseSensitivity (QCompleter::CaseSensitive);
completer->setCompletionMode (QCompleter::PopupCompletion);
LineEdit->setInputMask ("NNNNN-NNNNN-NNNNN-NNNNN;_");
LineEdit->setCompleter (completer);

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

20th October 2007, 18:57
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 (http://doc.trolltech.com/latest/qcompleter.html#CompletionMode-enum). I know it doesn't work very well either but at least it shows something. ;)

PS. You could send a suggestion (http://trolltech.com/bugreport-form) to the Trolls via task-tracker (http://trolltech.com/developer/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".