#include#include int main() { QStringList fruits{"apple", "banana", "orange", "apple", "banana"}; QSet uniqueFruits = fruits.toSet(); return 0; }
#includeIn this example, we have a QStringList with duplicates. We call the toSet() method to convert it to a QSet with only unique names. Then, we loop through each name in the QSet and print it using qDebug(). The package library for QStringList and QSet is Qt, which is a cross-platform application framework.#include #include int main() { QStringList names{"John", "Mike", "John", "Samantha", "Samantha", "Samantha"}; QSet uniqueNames = names.toSet(); for (auto name : uniqueNames) { qDebug() << name; } return 0; }