开发者

How to remove item from QQueue at index i

开发者 https://www.devze.com 2023-01-05 23:13 出处:网络
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 rethi

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

0

精彩评论

暂无评论...
验证码 换一张
取 消