It is used to store and manipulate strings that logically belong together. Essentially QStringList is a QValueList of TQString objects. Unlike QStrList, which stores pointers to characters, QStringList holds real TQString objects. It is the class of choice whenever you work with Unicode strings. QStringList is part of the TQt Template Library.
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.
.PP
.nf
.br
fonts.sort();
.br
cout << fonts.join( ", " ) << endl;
.br
// Output:
.br
// Courier, Courier New, Helvetica [Adobe], Helvetica [Cronyx], Times
Creates a copy of the list \fIl\fR. 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
Replaces every occurrence of the string \fIbefore\fR in the strings that constitute the string list with the string \fIafter\fR. Returns a reference to the string list.
.PP
If \fIcs\fR is TRUE, the search is case sensitive; otherwise the search is case insensitive.
.PP
Example:
.PP
.nf
.br
QStringList list;
.br
list << "alpha" << "beta" << "gamma" << "epsilon";
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Replaces every occurrence of the regexp \fIrx\fR in the string with \fIafter\fR. Returns a reference to the string list.
.PP
Example:
.PP
.nf
.br
QStringList list;
.br
list << "alpha" << "beta" << "gamma" << "epsilon";
.br
list.gres( QRegExp("^a"), "o" );
.br
// list == ["olpha", "beta", "gamma", "epsilon"]
.br
.fi
.PP
For regexps containing capturing parentheses, occurrences of \fB\1\fR, \fB\2\fR, ..., in \fIafter\fR are replaced with \fIrx\fR.cap(1), cap(2), ...
If you want to sort your strings in an arbitrary order consider using a QMap. For example you could use a QMap<TQString,TQString> to create a case-insensitive ordering (e.g. mapping the lowercase text to the text), or a QMap<int,TQString> to sort the strings by some integer index, etc.
Splits the string \fIstr\fR into strings wherever the regular expression \fIsep\fR occurs, and returns the list of those strings.
.PP
If \fIallowEmptyEntries\fR is TRUE, a null string is inserted in the list wherever the separator matches twice without intervening text.
.PP
For example, if you split the string "a,,b,c" on commas, split() returns the three-item list "a", "b", "c" if \fIallowEmptyEntries\fR is FALSE (the default), and the four-item list "a", "", "b", "c" if \fIallowEmptyEntries\fR is TRUE.
.PP
If \fIsep\fR does not match anywhere in \fIstr\fR, split() returns a single element list with the element containing the single string \fIstr\fR.
If \fIsep\fR is an empty string, the return value is a list of one-character strings: split( TQString( "" ), "four" ) returns the four-item list, "f", "o", "u", "r".