Hello,
I am looking for a simple way to do completion on this input:
(LOGIN )+
I fetch logins from a database and the user has a QLineEdit in which he can put LOGIN LOGIN LOGIN ...
I want to provide completion for each LOGIN
Thank you ;-)
Printable View
Hello,
I am looking for a simple way to do completion on this input:
(LOGIN )+
I fetch logins from a database and the user has a QLineEdit in which he can put LOGIN LOGIN LOGIN ...
I want to provide completion for each LOGIN
Thank you ;-)
What have you tried already? You need a simple model that will have an unlimited hierarchical list of logins and you need to set the completer to treat the space character as a tree separator. It's all in the docs...
In the docs there is two possibility: the one you shown and an other one from an exemple which subclasses the edit widget and takes the word under cursor and popup completion.
If i follow you proposition i have to subclasses QAbstractItemModel.
With the second choice i have to subclass QLineEdit.
I was thinking that there were a simpliest solution because this grammar is very simple to complete. I'll subclass QAbstractItemModel.
Thank you wysota :)
The line edit is supposed to contain a single text, thus completion replaces the entire text by default. You can tweak the behaviour if you provide custom slots that will manipulate the completion prefix and the line edit text properly. Otherwise you'll have to preapare such a simple model.