I was wondering if anyone knew of a Qt library method that can take two QStringList
and remove all of the strings contained in one list from the second list.
Remove strings contained in one QStringList, from another QStringList
4.7k Views Asked by Wes At
2
There are 2 best solutions below
0

There is no library function in QList
nor QStringList
.
But you can write your own method:
void remove(QStringList& list, const QStringList& toDelete){
QStringListIterator i(toDelete);
while(i.hasNext()){
list.removeAll(i.next());
}
}
You could use the
QList::toSet()
method and do somemy_set1.substract(my_set2)
, and then go backQSet::toList()
. But this is just to play around with conversion code. You'd better code the logic yourself with the given lists, it will be faster and won't involve useless memory allocation (even if temporary)