How to remove item from QQueue at index i.
A:
Qt documentation for,
T QQueue::dequeue ()
states that, Removes the head item in the queue and returns it. This function assumes that the queue isn't empty.
Hope it helps.
Edit:
If you want to remove item from a specific index, use QList
instead.
There are functions like,
void QList::removeAt ( int i )
and
T QList::takeAt ( int i )
which you can make use depending upon your need..
liaK
2010-07-08 11:14:19
It's good if the reason for downvote is made known.
liaK
2010-07-08 11:53:31
+2
A:
Being that QQueue is based on and will work like a std::queue, which is a FIFO (First-in First-out container), it seems you may need to rethink your usage of QQueue.
To remove the head item, use
QQueue::dequeue()
To remove an item at index i (using QList inherited functions)
QQueue::removeAt( int i )
If you need to do this, rethink your QQueue usage please.
(see Qt Documentation)
rubenvb
2010-07-08 11:17:52
It will not remove the last item. It will the remove the item at the head of the queue. From Qt documentation, dequeue() is equivalent to QList::takeFirst().. http://doc.trolltech.com/4.5/qqueue.html#dequeue .. It sums it up..
liaK
2010-07-08 11:56:25
A:
QQueue
inherits QList<T>
, so you can use void QList::removeAt(index)
inherited method.
Nick D
2010-07-08 11:18:13