#include <qstringlist.h>
Inheritance diagram for QStringList:


QStringList inherits from QList<QString>. Like QList, QStringList is {implicitly shared}. It provides fast index-based access as well as fast insertions and removals. Passing string lists as value parameters is both fast and safe.
All of QList's functionality also applies to QStringList. For example, you can use isEmpty() to test whether the list is empty, and you can call functions like append(), prepend(), insert(), replace(), and remove() to modify a QStringList. In addition, QStringList provides a few convenience functions that make handling lists of strings easier:
Strings can be added to a list using the \l {QList::append()}{append()}, \l {QList::operator+=()}{operator+=()} and \l {QStringList::operator<<()}{operator<<()} functions. For example: \quotefromfile snippets/qstringlist/main.cpp \skipto QStringList fonts \printuntil Courier @section Iterating over the strings To iterate over a list, you can either use index positions or QList's Java-style and STL-style iterator types: Indexing: \quotefromfile snippets/qstringlist/main.cpp \skipto for (int i = 0; i < fonts.size(); ++i) \printuntil cout << fonts.at(i).toLocal8Bit().constData() << end Java-style iterator: \quotefromfile snippets/qstringlist/main.cpp \skipto QStringListIterator \printuntil cout << javaStyleIterator STL-style iterator: \quotefromfile snippets/qstringlist/main.cpp \skipto QStringList::const_iterator \printuntil cout << (*constIterator) The QStringListIterator class is simply a type definition for QListIterator<QString>. QStringList also provide the QMutableStringListIterator class which is a type definition for QMutableListIterator<QString>. @section Manipulating the strings QStringList provides several functions allowing you to manipulate the contents of a list. You can concatenate all the strings in a string list into a single string (with an optional separator) using the join() function. For example: \quotefromfile snippets/qstringlist/main.cpp \skipto fonts.join \printuntil // str To break up a string into a string list, use the QString::split() function: \quotefromfile snippets/qstringlist/main.cpp \skipto QStringList list; \printuntil // list The argument to split can be a single character, a string, or a QRegExp. In addition, the \l {QStringList::operator+()}{operator+()} function allows you to concatenate two string lists into one. To sort a string list, use the sort() function. QString list also provides the filter() function which lets you to extract a new list which contains only those strings which contain a particular substring (or match a particular regular expression): \quotefromfile snippets/qstringlist/main.cpp \skipto monospacedFonts \printline monospacedFonts The contains() function tells you whether the list contains a given string, while the indexOf() function returns the index of the first occurrence of the given string. The lastIndexOf() function on the other hand, returns the index of the last occurrence of the string. Finally, the replaceInStrings() function calls QString::replace() on each string in the string list in turn. For example: \quotefromfile snippets/qstringlist/main.cpp \skipto QStringList files \printuntil // files \sa QString Definition at line 46 of file qstringlist.h.
| QStringList::QStringList | ( | ) | [inline] |
| QStringList::QStringList | ( | const QString & | str | ) | [inline, explicit] |
Constructs a string list that contains the given string, str. Longer lists are easily created like this:
snippets/qstringlist/main.cpp longerList longerList
Definition at line 50 of file qstringlist.h.
References i.
| QStringList::QStringList | ( | const QStringList & | other | ) | [inline] |
Constructs a copy of the other string list.
This operation takes {constant time} because QStringList is {implicitly shared}, making the process of returning a QStringList from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes {linear time}.
Definition at line 51 of file qstringlist.h.
00051 : QList<QString>(l) { }
Constructs a copy of other.
This operation takes {constant time}, because QStringList is {implicitly shared}. This makes returning a QStringList from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes {linear time}.
Definition at line 52 of file qstringlist.h.
00052 : QList<QString>(l) { }
| void QStringList::sort | ( | ) | [inline] |
Sorts the list of strings in ascending order (case sensitively).
Sorting is performed using Qt's qSort() algorithm, which operates in {linear-logarithmic time}, i.e. O({n} log {n}).
If you want to sort your strings in an arbitrary order, consider using the QMap class. For example, you could use a QMap<QString, QString> to create a case-insensitive ordering (e.g. with the keys being lower-case versions of the strings, and the values being the strings), or a QMap<int, QString> to sort the strings by some integer index.
Definition at line 123 of file qstringlist.h.
References QtPrivate::QStringList_sort().
Referenced by qdesigner_internal::objectNameList(), qdesigner_internal::OldSignalSlotDialog::populateSignalList(), qdesigner_internal::OldSignalSlotDialog::populateSlotList(), printAllServices(), removeDuplicates(), and QFont::substitutions().
00124 { 00125 QtPrivate::QStringList_sort(this); 00126 }
Here is the call graph for this function:

Joins all the string list's strings into a single string with each element separated by the the given separator (which can be an empty string).
Definition at line 128 of file qstringlist.h.
References QtPrivate::QStringList_join().
Referenced by combinePath(), Ui3Reader::createProperties(), qdesigner_internal::QDesignerResource::createProperty(), DomModel::data(), ProFileEvaluator::evaluateExpandFunction(), ProFileEvaluator::expandVariableReferences(), fixString(), getFullyQualifiedClassName(), getPropertyValue(), Config::loadDefaultProfile(), operator<<(), parse(), parseCmdLine(), QDateTimeParser::parseFormat(), QCompleter::pathFromIndex(), qt_from_ACE(), Launcher::readCategoryDescription(), ChatMainWindow::rebuildHistory(), Profile::removeDocFileEntry(), Config::saveProfile(), QSqlRelationalTableModel::selectStatement(), Dialog::setOpenFileNames(), and qdesigner_internal::StringListProperty::toString().
00129 { 00130 return QtPrivate::QStringList_join(this, sep); 00131 }
Here is the call graph for this function:

| QStringList QStringList::filter | ( | const QString & | str, | |
| Qt::CaseSensitivity | cs = Qt::CaseSensitive | |||
| ) | const [inline] |
Returns a list of all the strings containing the substring str.
If cs is Qt::CaseSensitive (the default), the string comparison is case sensitive; otherwise the comparison is case insensitive.
snippets/qstringlist/main.cpp QStringList list; QStringList list; list << "Bill Murray" // result
This is equivalent to
snippets/qstringlist/main.cpp QStringList result; QStringList result; foreach }
Definition at line 133 of file qstringlist.h.
References QtPrivate::QStringList_filter().
Referenced by HelpNavigationListItem::addLink(), Ui3Reader::createFormImpl(), and QProcessPrivate::execChild().
00134 { 00135 return QtPrivate::QStringList_filter(this, str, cs); 00136 }
Here is the call graph for this function:

| QBool QStringList::contains | ( | const QString & | str, | |
| Qt::CaseSensitivity | cs = Qt::CaseSensitive | |||
| ) | const [inline] |
Returns true if the list contains the string str; otherwise returns false. The search is case insensitive if cs is Qt::CaseInsensitive; the search is case sensitive by default.
Definition at line 138 of file qstringlist.h.
References QtPrivate::QStringList_contains().
Referenced by QFileSystemWatcherPrivate::_q_directoryChanged(), QFileSystemWatcherPrivate::_q_fileChanged(), Profile::addDCF(), Profile::addDCFTitle(), qdesigner_internal::ResourceModel::addFiles(), QInotifyFileSystemWatcherEngine::addPaths(), QKqueueFileSystemWatcherEngine::addPaths(), TrWindow::addRecentlyOpenedFile(), qdesigner_internal::FormWindow::addResourceFile(), QCss::StyleSelector::basicSelectorMatches(), QInternalMimeData::canReadData(), cleanInterfaces(), Ui3Reader::computeDeps(), SpreadSheetDelegate::createEditor(), Ui3Reader::createFormImpl(), QSqlDatabase::drivers(), DocuParser320::endElement(), TrWindow::findFormFilesInCurrentTranslationFile(), QInternalMimeData::formats(), QDropData::formats_sys(), QClipboardWatcher::formats_sys(), QInternalMimeData::formatsHelper(), Profile::hasDocFile(), QMimeData::hasFormat(), QClipboardWatcher::hasFormat_sys(), QDropData::hasFormat_sys(), QInternalMimeData::hasFormatHelper(), initDb(), QFont::insertSubstitution(), QFont::insertSubstitutions(), insertUnique(), QDesignerPluginManager::instance(), QSqlDatabase::isDriverAvailable(), Ui3Reader::isLayout(), QHttpHeader::keys(), QStyleFactory::keys(), Launcher::launchExample(), main(), makeArgNames(), Config::mimePaths(), Q3FileDialog::newFolderClicked(), qdesigner_internal::GraphicsPropertyEditor::populateCombo(), ProjectPorter::portProFile(), QXmlSimpleReaderPrivate::processElementEmptyTag(), QDropEvent::provides(), QSqlConnectionDialog::QSqlConnectionDialog(), qt_set_x11_resources(), Ui3Reader::registerObject(), QDesignerPluginManager::registerPlugin(), QPrinterDescription::samePrinter(), QSqlRelationalTableModel::selectStatement(), qdesigner_internal::ConnectionModel::setData(), qdesigner_internal::SignalSlotEditor::setSource(), qdesigner_internal::SignalSlotEditor::setTarget(), Launcher::showExampleSummary(), Skin::Skin(), Ui3Reader::unique(), and qdesigner_internal::WidgetBoxTreeView::widgetToItem().
00139 { 00140 return QtPrivate::QStringList_contains(this, str, cs); 00141 }
Here is the call graph for this function:

| QStringList & QStringList::replaceInStrings | ( | const QString & | before, | |
| const QString & | after, | |||
| Qt::CaseSensitivity | cs = Qt::CaseSensitive | |||
| ) | [inline] |
Returns a string list where every string has had the before text replaced with the after text wherever the before text is found. The before text is matched case-sensitively or not depending on the cs flag.
For example:
snippets/qstringlist/main.cpp QStringList list; QStringList list; list << "alpha" // list
Definition at line 143 of file qstringlist.h.
References QtPrivate::QStringList_replaceInStrings().
00144 { 00145 QtPrivate::QStringList_replaceInStrings(this, before, after, cs); 00146 return *this; 00147 }
Here is the call graph for this function:

| QStringList QStringList::operator+ | ( | const QStringList & | other | ) | const [inline] |
Returns a string list that is the concatenation of this string list with the other string list.
Definition at line 63 of file qstringlist.h.
References n.
00064 { QStringList n = *this; n += other; return n; }
| QStringList & QStringList::operator<< | ( | const QString & | str | ) | [inline] |
Appends the given string, str, to this string list and returns a reference to the string list.
Reimplemented from QList< QString >.
Definition at line 65 of file qstringlist.h.
00066 { append(str); return *this; }
| QStringList & QStringList::operator<< | ( | const QStringList & | other | ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Appends the other string list to the string list and returns a reference to the latter string list.
Definition at line 67 of file qstringlist.h.
References l.
00068 { *this += l; return *this; }
| QStringList QStringList::filter | ( | const QRegExp & | rx | ) | const [inline] |
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 rx.
Definition at line 156 of file qstringlist.h.
References QtPrivate::QStringList_filter().
00157 { 00158 return QtPrivate::QStringList_filter(this, rx); 00159 }
Here is the call graph for this function:

| QStringList & QStringList::replaceInStrings | ( | const QRegExp & | rx, | |
| const QString & | after | |||
| ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Replaces every occurrence of the regexp rx, in each of the string lists's strings, with after. Returns a reference to the string list.
For example:
snippets/qstringlist/main.cpp QStringList list; QStringList list; list << "alpha" list.clear() list << "alpha" // list
For regular expressions that contain {capturing parentheses}, occurrences of {\1}, {\2}, ..., in after are replaced with {rx}.cap(1), {rx}.cap(2), ...
For example:
snippets/qstringlist/main.cpp QStringList list; QStringList list; list << "Bill Clinton" << "Murray, Bill" // list
Definition at line 150 of file qstringlist.h.
References QtPrivate::QStringList_replaceInStrings().
00151 { 00152 QtPrivate::QStringList_replaceInStrings(this, rx, after); 00153 return *this; 00154 }
Here is the call graph for this function:

| int QStringList::indexOf | ( | const QRegExp & | rx, | |
| int | from = 0 | |||
| ) | const [inline] |
Returns the index position of the first exact match of rx in the list, searching forward from index position from. Returns -1 if no item matched.
Definition at line 161 of file qstringlist.h.
References QtPrivate::QStringList_indexOf().
Referenced by createReadHandler(), ProFileEvaluator::evaluateExpandFunction(), findAttribute(), qdesigner_internal::FontProperty::FontProperty(), imageReadMimeFormats(), imageWriteMimeFormats(), qdesigner_internal::MapProperty::indexOf(), TopicChooser::link(), QDirModel::mkdir(), parseBrushValue(), PeerManager::PeerManager(), QMultiInputContext::QMultiInputContext(), Q3SqlForm::remove(), and HelpDialog::showIndexTopic().
00162 { 00163 return QtPrivate::QStringList_indexOf(this, rx, from); 00164 }
Here is the call graph for this function:

| int QStringList::lastIndexOf | ( | const QRegExp & | rx, | |
| int | from = -1 | |||
| ) | const [inline] |
Returns the index position of the last exact match of rx in the list, searching backward from index position from. If from is -1 (the default), the search starts at the last item. Returns -1 if no item matched.
Definition at line 166 of file qstringlist.h.
References QtPrivate::QStringList_lastIndexOf().
Referenced by Q3FileDialog::selectedFiles().
00167 { 00168 return QtPrivate::QStringList_lastIndexOf(this, rx, from); 00169 }
Here is the call graph for this function:

QStringListIterator [related] |
The QStringListIterator type definition provides a Java-style const iterator for QStringList.
QStringList provides both {Java-style iterators} and {STL-style iterators}. The Java-style const iterator is simply a type definition for QListIterator<QString>.
QMutableStringListIterator [related] |
The QStringListIterator type definition provides a Java-style non-const iterator for QStringList.
QStringList provides both {Java-style iterators} and {STL-style iterators}. The Java-style non-const iterator is simply a type definition for QMutableListIterator<QString>.
| QDataStream & operator>> | ( | QDataStream & | in, | |
| QStringList & | list | |||
| ) | [related] |
Reads a string list from the given in stream into the specified list.
Definition at line 204 of file qstringlist.h.
00205 { 00206 return operator>>(in, static_cast<QList<QString> &>(list)); 00207 }
| QDataStream & operator<< | ( | QDataStream & | out, | |
| const QStringList & | list | |||
| ) | [related] |
Writes the given string list to the specified out stream.
Definition at line 208 of file qstringlist.h.
1.5.1