Qcompleter Rules
-
I'm making a Qcompleter for search fields and some QLineedits
I made a function that returns a List of all products and their code, exactly like this
['Samsung S21 - 00001', 'Keyboard - 00002', 'DDR4 Ram Memory - 3200mhz Skillre - 00005']However, I couldn't find a way to just display this view, and the text filling would be just the code or name
The way to implement it is to activate a Timer that clears the field, and uses a split to separate the code and overwrites, but I think it is a bad practice.
The text returned after pressing enter on the options:
It should be just 00001
-
Hi,
Why not have a model with two columns and a custom delegate that stitches them when showing the list ?
-
@Carlosyoot said in Qcompleter Rules:
I create two columns that turn into one item, and I just return part of that item?
No, just a model where you have two columns in each row (data entry).
One for your description likeSamsung S21
and one for your "code" or whatever data behind that, like00001
.
Then you create a simple delegate for that model to display the column of data you need from the model and set that delegate to your view.