QStringList list; list << "apple" << "banana" << "cherry";
QStringList list; list << "apple" << "banana" << "cherry"; qDebug() << list[1]; // prints "banana" qDebug() << list.first(); // prints "apple" qDebug() << list.last(); // prints "cherry"
QStringList list; list << "apple" << "banana" << "cherry"; QString result = list.join(", "); qDebug() << result; // prints "apple, banana, cherry"This code creates a list of strings, and then converts the list to a single string using the join() function of the QStringList class. The join() function takes a separator string as an argument and returns a single string that concatenates all the elements in the list, separated by the separator string. The QStringList class is part of the Qt core module, which is a part of the Qt framework. Therefore, to use the QStringList class, you need to have the Qt framework installed and linked to your C++ project.