PDA

View Full Version : iterate through QHash



rosenth
23rd May 2010, 05:49
I made a loop :


QHashIterator<QString, QString> i(customers);
while (i.hasNext())
{

QString dir=(i.value().left(1)=="-")?"1":"0";
...


but runtime error is on i.value():

The inferior stopped because it received a signal from
the operating system.
signal name: SIGABRT
signal meaning: Aborted
whats problem?

rosenth
23rd May 2010, 06:03
forget to add:

i.next();

Lykurg
23rd May 2010, 07:50
Hint: Instead of left() better use QString::startsWith() (or QString::at()) since their performance is more effective.

SixDegrees
23rd May 2010, 08:55
Try inspecting your hash table to see if what it contains makes sense. Try walking through it using hash.keys() instead of using an iterator; if that works, the problem lies with the iterator, not your hash table.