Hi folks,
I'm trying to find out, which class and how should I reimplement, to get duplicate values filter.
Exactly what I want to do, is just to put uniqe values from one of QStandardItemModel columns (that contains duplicates).
Best regards,
Kris
Hi folks,
I'm trying to find out, which class and how should I reimplement, to get duplicate values filter.
Exactly what I want to do, is just to put uniqe values from one of QStandardItemModel columns (that contains duplicates).
Best regards,
Kris
QSortFilterProxyModel -- you'll need to subclass it and reimplement filterAcceptsRow()
Thank you. I'm examining Custom Sort/Filter example, what I believe should help me.
But I'm just wondering how filter is beeing applyed to elements. Row by row?
I plan to put all unique values into QSet, and check it they exist there. Good track?
My only concideration is, to keep original order and remove elements following after first occurance.
Mad Bekon (15th April 2013)
Qt Code:
bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, { if(!(mySet.contains(index.data().toString()))) { const_cast<MySortFilterProxyModel *>(this)->mySet.insert(index.data().toString()); return true; } else return false; }To copy to clipboard, switch view to plain text mode
Did the job... Dzięki wielkie
Remember to clear the set when the filter is invalidated.
True, true...
I cannot edit, so I will add here:
Qt Code:
void MySortFilterProxyModel::invalidateFilter() { mySet.clear(); }To copy to clipboard, switch view to plain text mode
Bookmarks