Re: QCompleter - isslplpue
Re: QCompleter - isslplpue
Create a proxy model that will "flatten" your tree model. Then assign that proxy model to your completer.
Re: QCompleter - isslplpue
Hi
I did not actually get what do you mean by flattening the model. Does it happen by itself once i assign the source model to the proxy model or i have re-program it and break the hierarchy while building the proxy model.
Looking forward to more on this !!
Regards
Sajjad
Re: QCompleter - isslplpue
No, nothing happens by itself. By flattening I mean that the proxy model needs to transform the original model in such a way that all children of each item become siblings of that item so that you don't have children anymore and all elements are directly under the root of the model.
Re: QCompleter - isslplpue
Hi
I think that in this case i have subclass the QProxyModel and over-ride the following functions as follows:
I am not sure what would be inside the definition of those above functions . As per suggestion i need to flatten down the existing tree hierarchy model and send it to the QCompleter.
Some more hint or example is appreciated.
Regards
Sajjad
Re: QCompleter - isslplpue
Take a piece of paper, draw a schema of your tree model (including branches and children) and think what needs to be done step by step to obtain a situation where the model is flat. When you find the algorithm of recalculating model indexes, implement it in mapFromSource() and mapToSource().
Re: QCompleter - isslplpue
Hi
If i flatten down the tree hierarchy , it will eventually look like a list model, right?
Regards
Sajjad
Re: QCompleter - isslplpue
A list or a table model, depending on the number of columns your original model has.