You Are Here:

Community: Wiki

This page was last modified on 6 November 2009, at 08:30.

How to use QStringList in Qt for Symbian

From Forum Nokia Wiki

Reviewer Approved   



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


Overview

This code snippet demonstrates how to use QStringList in Qt for Symbian.


Various Function

  • To make a String List.
QStringList name,namesplit;
name << "james 1980" << "james bond" << "paul" << "jonny joker";
  • To join all the string in string list.
str1 = name.join(",");//str1="james 1980,james bond,paul,jonny joker"
  • To break up a string into a string list.
namesplit = str1.split(",");// namesplit is same as name
  • Extract a new list which contains only those strings which contain a particular substring (or match a particular regular expression).
namesplit = name.filter("james");//namesplit = ["james1980","james bond"]
  • To replace String.
namesplit.replaceInStrings("a", "o");

Preconditions


Code Snippet

#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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fHowE5ftoE5fsendE5fandE5freceiveE5fmessagesE5finE5fE51tE5fforE5fSymbianX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZE71tQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxE71tX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ