#include#include int main() { QStringList fruits = {"apple", "banana", "orange"}; int length = fruits.length(); qDebug() << "Number of fruits:" << length; return 0; }
#includeThis code splits a string "apple,banana,orange" using the comma delimiter and creates a QStringList from the resulting list. The length() function is used to print the number of fruits in the list. Package Library: Qt Library.#include int main() { QString str = "apple,banana,orange"; QStringList fruits = str.split(","); int length = fruits.length(); qDebug() << "Number of fruits:" << length; return 0; }