Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, September 2007
QStringList


Message 1 in thread

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?

Message 2 in thread

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.


Message 3 in thread

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 ]