PDA

View Full Version : clearing a qlist..



reshma
14th March 2009, 04:39
hiii

i have such kind of lists...
QList<QPair<QString, int> > instructionList;
QList<QPair<int, int> > issuedinstrlist;

i tried clear() but when i tried to re-enter values its showing error..

again qDeleteAll() is not working...

so what do i do

all i need is that the elements in this qlist be cleared such that next tim i work on it it would start a new list...

aamer4yu
14th March 2009, 06:21
Yours is not a case of pointers, so qDeleteAll is not so appropriate
How are you adding values ? cant say much without seeing code.

Also please try to confine your problem to one thread. Its not that people wont read the old thread

reshma
14th March 2009, 11:27
ok this is how i m populatin the list:


QPair<QString, int> item;
str=QString(instr[i]);
item.first = str;
item.second = k;
instructionList.append(item);

now help me out??

wysota
14th March 2009, 13:16
clear() should work fine. If you receive errors you might want to share them with us.

reshma
15th March 2009, 06:41
this is the error i got....

ASSERT FAILURE IN QList<T>::operator[]:"index out of range"

wat do i do next??

Lykurg
15th March 2009, 08:23
ASSERT FAILURE IN QList<T>::operator[]:"index out of range"

Ok, thats not an error you get when using clear() right. What's your code? By the way the error is self explaining, isn't it?

int i;
QList<T> list;
// some content in list
list[i] = ...; // and this throws the error because i >= list.count()!