How to remove item from QQ开发者_如何学运维ueue at index i.
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)
QQueue
inherits QList<T>
, so you can use void QList::removeAt(index)
inherited method.
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..
精彩评论