if you do not care about the order of the list:
sl = sl.toSet().toList();
QStringList sl = ...;
sl = sl.toSet().toList();
To copy to clipboard, switch view to plain text mode
Maybe there are more efficient ways to do that.
Or you could do
for (int i=0; i<sl.count(); ++i)
{
forever { // remove all occurrences at greater indexes
int p=sl.lastIndexOf(sl.at[i]);
if (p==i) break;
sl.removeAt(p);
}
}
for (int i=0; i<sl.count(); ++i)
{
forever { // remove all occurrences at greater indexes
int p=sl.lastIndexOf(sl.at[i]);
if (p==i) break;
sl.removeAt(p);
}
}
To copy to clipboard, switch view to plain text mode
Untested, of course. Have, fun!
Bookmarks