greshi Gupta
greshi Gupta

Reputation: 1241

How to remove item from QQueue at index i

How to remove item from QQueue at index i.

Upvotes: 0

Views: 1691

Answers (3)

liaK
liaK

Reputation: 11648

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

Upvotes: -1

rubenvb
rubenvb

Reputation: 76519

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)

Upvotes: 5

Nick Dandoulakis
Nick Dandoulakis

Reputation: 43110

QQueue inherits QList<T>, so you can use void QList::removeAt(index) inherited method.

Upvotes: 1

Related Questions