| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 4 | |
I have a QStringList - I need to take that list - split each string within that list, then store it in a QMap. I know how to split strings and put them into a string list. How do I split strings within a string list?
Ann Marie wrote:
>I have a QStringList - I need to take that list - split each string
> within that list, then store it in a QMap.
>
>I know how to split strings and put them into a string list. How do I
> split strings within a string list?
Do it for each string in the string list.
Using the foreach() macro may be of help:
QMap<QString,QString> map;
foreach (QString s, stringlist) {
QStringList split = s.split(<insert here your rules>)
map[split.at(0)] = split.at(1);
}
--
[ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.
quint32 key(0);
QList<QString>::iterator aString;
QMap<quint32, QString> aMap;
aString = aStringList..begin();
while (aString != aStringList.end())
{
aMap[key++] = *aString;
aString++;
}
Does this help?
On Sep 19, 2007, at 10:55 AM, Ann Marie wrote:
> I have a QStringList - I need to take that list - split each string
> within that list, then store it in a QMap.
>
> I know how to split strings and put them into a string list. How
> do I split strings within a string list?
>
>
--
[ signature omitted ]