c++qtqstringlist

Remove strings contained in one QStringList, from another QStringList


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.


Solution

  • You could use the QList::toSet() method and do some my_set1.substract(my_set2), and then go back QSet::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)