It depends on how is your data storen and passed to the view. Generally, the simpliest way to remove duplicates from a list of element is converting it to set:
QStringList values;
//...
QSet<QString> set = values.toSet();
After that you can convert the set back to list using toList
or iterate over a set using usual foreach
loop. Note that QSet
is unordered. If you want to sort your strings, convert the set to list and sort the list using qSort
.