| ID | ... | Creation date | 17 January 2009 |
| Platform | S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition | Tested on devices | Emulator |
| Category | Qt for Symbian | Subcategory |
| Keywords (APIs, classes, methods, functions): QStringList |
This code snippet demonstrates how to use QStringList in Qt for Symbian.
QStringList name,namesplit; name << "james 1980" << "james bond" << "paul" << "jonny joker";
str1 = name.join(",");//str1="james 1980,james bond,paul,jonny joker"
namesplit = str1.split(",");// namesplit is same as name
namesplit = name.filter("james");//namesplit = ["james1980","james bond"]
namesplit.replaceInStrings("a", "o");
#include <QApplication>
#include <QString>
#include <QStringList>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QString str = "world";
QString str1;
QStringList name,namesplit;
name << "james 1980" << "james bond" << "paul" << "jonny joker";
str1 = name.join(",");//str1="james 1980,james bond,paul,jonny joker"
namesplit = str1.split(",");// namesplit is same as name
namesplit = name.filter("james");//namesplit = ["james1980","james bond"]
bool a = name.contains(str);//Returns true if the list contains the string str; otherwise returns false.
namesplit.replaceInStrings("a", "o");// Replace all the occurrence of "a" with "o"
name.sort();//Sorts the list of strings in ascending order (case sensitively).
return app.exec();
}
For more details in QStringList visit: http://pepper.troll.no/s60prereleases/doc/qstringlist.html Originally by James1980, updates by Mind Freak