How to have multiple QCompleters in one QLineEdit
-
Hi,
I checked the web and could not find an answer to this issue I'm trying to solve. Perhaps someone can help me.
I'd like to have several QCompleters in the same QLineEdit and allow users to select an element in each completer independent of the others:
QCompleter1 QCompleter2 QCompleter3 ….
Users can go and select an element in QCompleter2 without affecting the other two.
Would anyone know how to do this?
Thanks and appreciate your help.
-
Derive from QCompleter and write your logic.
-
Hi,
A maybe simpler way would be to have several models based on the sources you have and then use KConcatenateRowsProxyModel to put them together.
You might also want to explain a bit more your design.
-
Basically what I want to do is allow users to query a database and essentially create their own query parameters. What I was thinking is to have multiple completers in a row where each completer represents a separate list of parameters. i.e. completer1 is a list of tables which they select. Once they select a table, the second completer shows all the attributes for that table. Once they select the attribute, a third completer shows the possible values which are associated with the attribute. Once they make the selections along with some math logic, I extract the selections and build a query.
I an easily create a whole lot of comb-boxes with , lineEdits and completers and do it that way but I thought a nice long lineEdit with a single combo-box to save past queries would be much nicer.
Ideally all under one LineEdit and combo-box if possible:
table completer, attribute completer, math completer (>,>=, <, etc), value completer, Boolean completer (AND/OR) for next query, continue again …Is this possible? If so how can I implement this sort of feature?
Thanks.
-
@leinad said in How to have multiple QCompleters in one QLineEdit:
I an easily create a whole lot of comb-boxes with , lineEdits and completers and do it that way but I thought a nice long lineEdit
Which would be one's natural thought, with separate
QCompleter
s. You want to somehow do what? Have a line that is kind of completed left-to-right, and after the first element of the line has been completed that affects what the other completers show for the next element in the line? What happens if I want to go back and change my mind about the first element I previously picked? Are you planning to look at where I click on the line to decide which of your 3 completers to activate? Or what...? -
@leinad
I'm thinking you can just have oneQCompleter
: you recognise your click, determine which set of completions you want and the corresponding text typed so far depending on position, invoke the completer, and do whatever to copy back if the user picks something? Or three separate ones to maintain state but same principle? The problem is perhaps recognising just where the click is so that you decide which completions you want to offer?