#include </home/clem/local/src/opie/qmake/include/qstringlist.h>
Inheritance diagram for QStringList:


Public Member Functions | |
| QStringList () | |
| QStringList (const QStringList &l) | |
| QStringList (const QValueList< QString > &l) | |
| QStringList (const QString &i) | |
| QStringList (const char *i) | |
| void | sort () |
| QString | join (const QString &sep) const |
| QStringList | grep (const QString &str, bool cs=TRUE) const |
| QStringList | grep (const QRegExp &expr) const |
Static Public Member Functions | |
| static QStringList | fromStrList (const QStrList &) |
| static QStringList | split (const QString &sep, const QString &str, bool allowEmptyEntries=FALSE) |
| static QStringList | split (const QChar &sep, const QString &str, bool allowEmptyEntries=FALSE) |
| static QStringList | split (const QRegExp &sep, const QString &str, bool allowEmptyEntries=FALSE) |
It is used to store and manipulate strings that logically belong together. Essentially QStringList is a QValueList of QString objects. Unlike QStrList, which stores pointers to characters, QStringList holds real QString objects. It is the class of choice whenever you work with Unicode strings. QStringList is part of the Qt Template Library.
Like QString itself, QStringList objects are implicitly shared. Passing them around as value-parameters is both fast and safe.
Strings can be added to a list using append(), operator+=() or operator<<(), e.g.
QStringList fonts; fonts.append( "Times" ); fonts += "Courier"; fonts += "Courier New"; fonts << "Helvetica [Cronyx]" << "Helvetica [Adobe]";
String lists have an iterator, QStringList::Iterator(), e.g.
for ( QStringList::Iterator it = fonts.begin(); it != fonts.end(); ++it ) { cout << *it << ":"; } cout << endl; // Output: // Times:Courier:Courier New:Helvetica [Cronyx]:Helvetica [Adobe]:
Many Qt functions return const string lists; to iterate over these you should make a copy and iterate over the copy.
You can concatenate all the strings in a string list into a single string (with an optional separator) using join(), e.g.
QString allFonts = fonts.join( ", " ); cout << allFonts << endl; // Output: // Times, Courier, Courier New, Helvetica [Cronyx], Helvetica [Adobe]
You can sort the list with sort(), and extract a new list which contains only those strings which contain a particular substring (or match a particular regular expression) using the grep() functions, e.g.
fonts.sort(); cout << fonts.join( ", " ) << endl; // Output: // Courier, Courier New, Helvetica [Adobe], Helvetica [Cronyx], Times QStringList helveticas = fonts.grep( "Helvetica" ); cout << helveticas.join( ", " ) << endl; // Output: // Helvetica [Adobe], Helvetica [Cronyx]
Existing strings can be split into string lists with character, string or regular expression separators, e.g.
QString s = "Red\tGreen\tBlue"; QStringList colors = QStringList::split( "\t", s ); cout << colors.join( ", " ) << endl; // Output: // Red, Green, Blue
Definition at line 51 of file qstringlist.h.
|
|
Creates an empty string list. Definition at line 54 of file qstringlist.h. |
|
|
Creates a copy of the list l. This function is very fast because QStringList is implicitly shared. In most situations this acts like a deep copy, for example, if this list or the original one or some other list referencing the same shared data is modified, the modifying list first makes a copy, i.e. copy-on-write. In a threaded environment you may require a real deep copy see QDeepCopy. Definition at line 55 of file qstringlist.h. |
|
|
Constructs a new string list that is a copy of l. Definition at line 56 of file qstringlist.h. |
|
|
Constructs a string list consisting of the single string i. Longer lists are easily created as follows:
QStringList items; items << "Buy" << "Sell" << "Update" << "Value"; Definition at line 57 of file qstringlist.h. References QValueList< T >::append(). |
|
|
Constructs a string list consisting of the single latin-1 string i. Definition at line 59 of file qstringlist.h. References QValueList< T >::append(). |
|
|
Converts from an ASCII-QStrList ascii to a QStringList (Unicode). Definition at line 367 of file qstringlist.cpp. References s. Referenced by Konsole::init(). |
|
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns a list of all the strings that match the regular expression expr. Definition at line 321 of file qstringlist.cpp. References QValueList< QString >::begin(), and QValueList< QString >::end(). |
|
||||||||||||
|
Returns a list of all strings containing the substring str. If cs is TRUE, the grep is done case-sensitively; otherwise case is ignored. Definition at line 303 of file qstringlist.cpp. References QValueList< QString >::begin(), and QValueList< QString >::end(). Referenced by Passwd::addGroupMember(), MainWindowImp::addProfile(), UserDialog::editUser(), Process::exec(), OpieFtp::fillCombo(), AdvancedFm::fillCombo(), OpieFtp::fillRemoteCombo(), Interfaces::isAuto(), OPackageManager::loadAvailablePackages(), OPackageManager::loadInstalledPackages(), MultiauthConfig::loadPlugins(), QMakeProject::parse(), DingWidget::parseInfo(), SmtpHandler::readyRead(), AdvancedFm::removeCustomDir(), Passwd::searchGroup(), Passwd::searchUser(), and QProcess::start(). |
|
|
|
||||||||||||||||
|
Splits the string str into strings wherever the regular expression sep occurs, and returns the list of those strings. If allowEmptyEntries is TRUE, an empty string is inserted in the list wherever the separator matches twice without intervening text. For example, if you split the string "a,,b,c" on commas, split() returns the three-item list "a", "b", "c" if allowEmptyEntries is FALSE (the default), and the four-item list "a", "", "b", "c" if allowEmptyEntries is TRUE. If sep does not match anywhere in str, split() returns a list consisting of the single string str.
Definition at line 264 of file qstringlist.cpp. References i, l, QString::length(), QRegExp::matchedLength(), QString::mid(), QString::null, and QRegExp::search(). |
|
||||||||||||||||
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This version of the function uses a QChar as separator, rather than a regular expression.
Definition at line 195 of file qstringlist.cpp. References split(). |
|
||||||||||||||||
1.4.2