PDA

View Full Version : QList



sabeesh
21st September 2007, 13:00
Hi,

I have seen a member function for QList in QT 2.3.6 named as " prev() "
which returns a pointer to the item preceding the current item. Returns null if the current item is null or equal to the first item.

and another member function take()
which Takes the current item out of the list without deleting it (even if auto-deletion is enabled). Returns a pointer to the item taken out of the list, or null if the current item is null.

I need to use this in QT4.3. How can I use it? which member function I can use ?
Please help me...

marcel
21st September 2007, 13:13
You have QList::takeAt as the equivalent of take.

There's no equivalent for prev however. You could implement your own very easy: find the index of your current item and get the item at the previous index, if the index is valid.

Or you could use iterators.

sabeesh
21st September 2007, 13:58
Hi,
But takeAt -> Removes the item at index position i and returns it.
and take -> Takes the current item out of the list without deleting it
Then how can I use it?
:confused:

marcel
21st September 2007, 14:00
But takeAt doesn't delete it either. Just removes it from the list and returns it.

ToddAtWSU
21st September 2007, 20:32
You said it yourself when you said


But takeAt -> Removes the item at index position i and returns it.

It returns the item therefore it doesn't delete it. Just use the returned item and your problem should be solved for the takeAt function.