Results 1 to 6 of 6

Thread: clearing a qlist..

  1. #1
    Join Date
    Mar 2009
    Posts
    18
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question clearing a qlist..

    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...

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: clearing a qlist..

    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

  3. #3
    Join Date
    Mar 2009
    Posts
    18
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: clearing a qlist..

    ok this is how i m populatin the list:
    Qt Code:
    1. QPair<QString, int> item;
    2. str=QString(instr[i]);
    3. item.first = str;
    4. item.second = k;
    5. instructionList.append(item);
    To copy to clipboard, switch view to plain text mode 

    now help me out??
    Last edited by jpn; 15th March 2009 at 10:44. Reason: missing [code] tags

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: clearing a qlist..

    clear() should work fine. If you receive errors you might want to share them with us.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2009
    Posts
    18
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: clearing a qlist..

    this is the error i got....

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

    wat do i do next??

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: clearing a qlist..

    Quote Originally Posted by reshma View Post
    ASSERT FAILURE IN QList<T>:perator[]:"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?
    Qt Code:
    1. int i;
    2. QList<T> list;
    3. // some content in list
    4. list[i] = ...; // and this throws the error because i >= list.count()!
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Sorting using qSort(), - if QList contains POINTERS
    By joseph in forum Qt Programming
    Replies: 13
    Last Post: 18th August 2013, 18:55
  2. QList, copy problems
    By Valheru in forum Qt Programming
    Replies: 4
    Last Post: 5th February 2010, 00:06
  3. Q3Ptrlist v/s QList
    By joseph in forum Qt Programming
    Replies: 3
    Last Post: 25th September 2007, 11:27
  4. QList
    By dragon in forum Qt Programming
    Replies: 11
    Last Post: 9th May 2007, 20:15
  5. Accessing QList Objects
    By magikalpnoi in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2006, 20:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.